:root {
  --verde: #009E62;
  --verde-claro: #E6F4EE;
  --amarillo: #FFCD00;
  --texto: #1F2937;
  --gris: #6B7280;
  --linea: #D1D5DB;
  --fondo: #F3F4F6;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: "Segoe UI", Calibri, Arial, sans-serif; font-size: 14px; color: var(--texto); background: var(--fondo); }
button, input, select, textarea { font: inherit; }

.barra-sup { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; padding: 8px 16px; background: #fff; border-bottom: 3px solid var(--verde); position: sticky; top: 0; z-index: 20; }
.marca { color: var(--verde); margin-right: 8px; }
.boton { display: inline-block; padding: 6px 12px; border-radius: 6px; border: 1px solid var(--verde); background: var(--verde); color: #fff; cursor: pointer; }
.boton:disabled { opacity: .5; cursor: default; }
.boton.pide { box-shadow: 0 0 0 3px #f5a623; animation: pide 1s ease-in-out 4; }
@keyframes pide { 50% { box-shadow: 0 0 0 7px rgba(245, 166, 35, .35); } }
.boton-sec { padding: 4px 10px; border-radius: 6px; border: 1px solid var(--linea); background: #fff; color: var(--texto); cursor: pointer; }
.boton-sec:hover { border-color: var(--verde); }
.dato { color: var(--gris); font-size: 12px; max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.estado { margin-left: auto; color: var(--gris); font-size: 12px; }

.pestanas { display: flex; gap: 4px; padding: 6px 16px 0; overflow-x: auto; }
.pestanas button { border: 1px solid var(--linea); border-bottom: none; background: #E5E7EB; padding: 6px 12px; border-radius: 6px 6px 0 0; cursor: pointer; white-space: nowrap; }
.pestanas button.activa { background: #fff; color: var(--verde); font-weight: 600; }
.pestanas .quitar { margin-left: 8px; color: var(--gris); }

.principal { display: grid; grid-template-columns: minmax(0, 1fr) 540px; gap: 12px; padding: 0 16px 16px; align-items: start; }
.zona-hoja { background: #fff; border: 1px solid var(--linea); min-width: 0; }
.herramientas-hoja { display: flex; justify-content: space-between; gap: 12px; padding: 6px 10px; border-bottom: 1px solid var(--linea); color: var(--gris); font-size: 12px; }
.contenedor-hoja { overflow: auto; max-height: calc(100vh - 150px); }

.panel { display: flex; flex-direction: column; gap: 10px; position: sticky; top: 70px; max-height: calc(100vh - 80px); overflow: auto; }
.bloque { background: #fff; border: 1px solid var(--linea); border-radius: 8px; padding: 10px 12px; }
.bloque h2 { font-size: 14px; margin: 0 0 8px; color: var(--verde); display: flex; justify-content: space-between; align-items: center; }
.ancho { width: 100%; padding: 5px 8px; border: 1px solid var(--linea); border-radius: 6px; }
.ayuda { color: var(--gris); font-size: 12px; margin: 0 0 6px; }
.notas { margin: 6px 0 0; padding-left: 18px; color: #92400E; font-size: 12px; }
.notas:empty { display: none; }
.rejilla-ajustes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px 8px; }
.rejilla-ajustes label { display: flex; flex-direction: column; font-size: 12px; color: var(--gris); }
.rejilla-ajustes input, .rejilla-ajustes output { padding: 3px 6px; border: 1px solid var(--linea); border-radius: 4px; color: var(--texto); min-height: 26px; }
.rejilla-ajustes output { background: var(--fondo); }
.potencias { margin-top: 6px; }
.acciones { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.umbral { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 12px; color: var(--gris); margin-bottom: 6px; }
.umbral input:not([type]) { width: 44px; padding: 2px 4px; border: 1px solid var(--linea); border-radius: 4px; }
.sugerencias { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-bottom: 8px; }
.sugerencia { border: 1px solid var(--linea); border-left: 4px solid var(--verde); border-radius: 6px; padding: 6px 8px; font-size: 12px; }
.sugerencia.colab { border-left-color: var(--amarillo); }
.sugerencia b { display: block; font-size: 13px; }
.sugerencia .tipo { color: var(--gris); text-transform: uppercase; font-size: 10px; letter-spacing: .04em; }
.tabla-scroll { max-height: 300px; overflow: auto; border: 1px solid var(--linea); border-radius: 6px; }
.candidatas { width: 100%; border-collapse: collapse; font-size: 11.5px; }
.candidatas th { position: sticky; top: 0; background: var(--fondo); text-align: left; font-weight: 600; padding: 4px 6px; }
.candidatas td { padding: 3px 4px; border-top: 1px solid #EEE; white-space: nowrap; }
.candidatas td.num { text-align: right; font-variant-numeric: tabular-nums; }
.candidatas tr.sin-ahorro td { color: #9CA3AF; }
.candidatas tr.elegida td { background: var(--verde-claro); }
.candidatas tr.en-hoja td:nth-child(2) { font-weight: 700; }
.etiqueta { display: inline-block; font-size: 10px; padding: 0 4px; border-radius: 3px; background: var(--verde); color: #fff; margin-left: 4px; }
.etiqueta.colab { background: var(--amarillo); color: #000; }
.correo { width: 100%; min-height: 320px; padding: 8px; border: 1px solid var(--linea); border-radius: 6px; font-family: "Segoe UI", Calibri, sans-serif; font-size: 13px; }

.bienvenida { max-width: 640px; margin: 48px auto; background: #fff; border: 1px solid var(--linea); border-radius: 8px; padding: 24px 32px; }
.bienvenida h1 { color: var(--verde); margin-top: 0; }

/* ---- the Excel sheet ---- */
.hoja-tabla { border-collapse: collapse; table-layout: fixed; }
.contenedor-hoja .hoja-tabla { background: #fff; }
.hoja-tabla td { padding: 0 2px; overflow: visible; line-height: 1.05; position: relative; }
.hoja-tabla.rejilla td { border: 1px solid #E2E2E2; }
/* Excel lets a text that does not fit run over the next cells: to the right if left-aligned, to the left if
   right-aligned, both ways if centred. A flex box with the same justification overflows the same way. */
.hoja-tabla .c { display: flex; justify-content: flex-start; overflow: visible; white-space: inherit; position: relative; z-index: 1; }
.hoja-tabla .c.a-right { justify-content: flex-end; }
.hoja-tabla .c.a-center { justify-content: center; }
.hoja-tabla .c.ajuste { display: block; }
.hoja-tabla .dividido { display: flex; justify-content: space-between; }
.hoja-tabla td.editable { cursor: pointer; }
.hoja-tabla td.editable:hover { outline: 2px solid var(--verde); outline-offset: -2px; }
.hoja-tabla .editor { position: absolute; inset: 0; width: 100%; min-width: 120px; height: 100%; z-index: 5; border: 2px solid var(--verde); font-size: 12px; padding: 0 4px; background: #fff; }
.hoja-imagen { pointer-events: none; }

/* ---- the offer PDF ---- */
.vista-pdf { position: fixed; inset: 0; z-index: 50; background: #525659; overflow: auto; }
.barra-pdf { position: sticky; top: 0; display: flex; gap: 10px; align-items: center; padding: 8px 16px; background: #fff; z-index: 2; }
#paginas { padding: 16px 0; }
.pagina { position: relative; width: 210mm; height: 297mm; overflow: hidden; background: #fff; margin: 0 auto 16px; box-shadow: 0 2px 8px rgba(0,0,0,.4);
  -webkit-print-color-adjust: exact; print-color-adjust: exact; }
.pagina .fondo { position: absolute; left: 0; top: 0; }
.pagina .contenido { position: absolute; }

@page { size: A4; margin: 0; }
@media print {
  body.imprimiendo > :not(#vista-pdf) { display: none !important; }
  body.imprimiendo { background: #fff; }
  .vista-pdf { position: static; background: none; overflow: visible; }
  .barra-pdf { display: none; }
  #paginas { padding: 0; }
  .pagina { margin: 0; box-shadow: none; break-after: page; }
}
@media (max-width: 1100px) {
  .principal { grid-template-columns: 1fr; }
  .panel { position: static; max-height: none; }
}

/* ---- invoices read from PDF (lectura.mjs) ---- */
.rejilla-ajustes select { padding: 3px 6px; border: 1px solid var(--linea); border-radius: 4px; color: var(--texto); min-height: 26px; background: #fff; }
.datos-cliente { grid-template-columns: 1fr 1fr; margin-top: 6px; }
.panel .pendiente { border-color: #D97706 !important; background: #FFFBEB; }
.pendientes { color: #92400E; font-size: 12px; font-weight: 600; margin: 0 0 6px; }
.aviso-dir { background: #FEF3C7; border-left: 3px solid #F59E0B; color: #92400E; font-size: 12px; margin: 6px 0; padding: 6px 8px; border-radius: 4px; }
.boton-sec.activo { border-color: var(--verde); background: var(--verde-claro); font-weight: 600; }
.texto-factura { max-height: 240px; overflow: auto; font-size: 11px; background: var(--fondo); padding: 6px; white-space: pre-wrap; }
.soltar { position: fixed; inset: 12px; z-index: 60; display: flex; align-items: center; justify-content: center; border: 3px dashed var(--verde);
  border-radius: 12px; background: rgba(230, 244, 238, .92); color: var(--verde); font-size: 22px; font-weight: 600; pointer-events: none; }
.soltar[hidden] { display: none; }
/* gas: electricity or gas quick settings */
.rejilla-ajustes[hidden] { display: none; }
.tipo-suministro { font-size: 12px; font-weight: 400; color: var(--gris); }
.tipo-suministro select { margin-left: 4px; padding: 2px 4px; border: 1px solid var(--linea); border-radius: 4px; }
