/* ============================================================
   Portal de Entrega de Datos - NETZA E.A.S.
   Estilo sobrio, cuadrado, corporate. Paleta neutra con acento azul marino.
   ============================================================ */

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 15px;
  color: #1f2937;
  background: #f3f4f6;
  line-height: 1.55;
}

/* ------------------ AVISO DE TIEMPO (VENTAS) ------------------ */

.aviso-tiempo {
  position: sticky;
  top: 0;
  z-index: 100;
  background: #fff4e5;
  border-bottom: 3px solid #e0a800;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  animation: aviso-in 0.25s ease-out;
}

.aviso-tiempo[hidden] {
  display: none;
}

.aviso-tiempo__inner {
  max-width: 1080px;
  margin: 0 auto;
  padding: 14px 24px;
  display: flex;
  align-items: flex-start;
  gap: 14px;
}

.aviso-tiempo__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  background: #e0a800;
  color: #fff;
  font-weight: 800;
  font-size: 20px;
  flex-shrink: 0;
}

.aviso-tiempo__texto strong {
  display: block;
  font-size: 14px;
  color: #3f3200;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 2px;
}

.aviso-tiempo__texto p {
  margin: 0;
  font-size: 13px;
  color: #3f3200;
  line-height: 1.5;
}

@keyframes aviso-in {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ------------------ TOPBAR ------------------ */

.topbar {
  background: #0b2545;
  color: #fff;
  border-bottom: 3px solid #13315c;
}

.topbar__inner {
  max-width: 1080px;
  margin: 0 auto;
  padding: 16px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.topbar__brand {
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.brand-mark {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: 1px;
  background: #fff;
  color: #0b2545;
  padding: 4px 10px;
}

.brand-name {
  font-size: 14px;
  letter-spacing: 2px;
  color: #cbd5e1;
}

.topbar__meta {
  font-size: 13px;
  color: #cbd5e1;
}

/* ------------------ CONTAINER ------------------ */

.container {
  max-width: 1080px;
  margin: 0 auto;
  padding: 28px 24px 60px;
}

.card {
  background: #fff;
  border: 1px solid #d1d5db;
  padding: 24px 28px;
  margin-bottom: 22px;
}

.card h1 {
  margin: 0 0 12px;
  font-size: 26px;
  color: #0b2545;
  font-weight: 700;
}

.card h2 {
  margin: 0 0 14px;
  font-size: 19px;
  color: #0b2545;
  font-weight: 700;
  padding-bottom: 8px;
  border-bottom: 2px solid #e5e7eb;
}

.card h3 {
  margin: 20px 0 10px;
  font-size: 15px;
  color: #0b2545;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.card p {
  margin: 0 0 12px;
  color: #374151;
}

/* ------------------ HERO ------------------ */

.card--hero {
  background: #fff;
  border-left: 6px solid #0b2545;
}

.hero__sub {
  font-size: 15px;
  color: #374151;
}

/* ------------------ LEGAL ------------------ */

.card--legal {
  background: #fafafa;
  border: 1px solid #d1d5db;
}

.candado {
  background: #fff8e1;
  border: 2px solid #e0a800;
  padding: 18px 22px;
  margin: 14px 0 20px;
}

.candado ol {
  margin: 10px 0 10px 18px;
  padding: 0;
}

.candado ol li {
  margin-bottom: 8px;
  color: #3f3200;
}

.candado__foot {
  margin-top: 12px;
  font-size: 13px;
  font-style: italic;
  color: #3f3200;
}

.aviso-mail {
  background: #eef6ff;
  border-left: 4px solid #0b2545;
  padding: 12px 16px;
  font-size: 13px;
  color: #1f3d67;
  margin: 14px 0;
}

.acept {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 14px 16px;
  background: #eef2f7;
  border: 1px solid #94a3b8;
  margin: 14px 0 18px;
  cursor: pointer;
  user-select: none;
}

.acept input[type="checkbox"] {
  margin-top: 3px;
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  cursor: pointer;
}

.acept span {
  color: #1f2937;
  font-weight: 600;
  line-height: 1.45;
}

.identidad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin-top: 6px;
}

.identidad--2 {
  grid-template-columns: repeat(2, 1fr);
}

.cod-ayuda {
  font-size: 11px;
  color: #475569;
  margin-top: 4px;
  font-style: italic;
  line-height: 1.4;
}

.cod-estado {
  font-size: 12px;
  margin-top: 4px;
  font-weight: 600;
  min-height: 16px;
}

.cod-estado--ok {
  color: #1f7a38;
}

.cod-estado--err {
  color: #b91c1c;
}

.cod-estado--check {
  color: #6b7280;
  font-style: italic;
}

.identidad label {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.identidad label span {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #475569;
  font-weight: 600;
}

.identidad input {
  padding: 9px 12px;
  border: 1px solid #94a3b8;
  background: #fff;
  font-size: 14px;
  font-family: inherit;
  color: #1f2937;
}

.email-fijo {
  padding: 9px 12px;
  border: 1px solid #94a3b8;
  background: #f1f5f9;
  font-size: 14px;
  color: #0b2545;
  font-weight: 600;
  font-family: ui-monospace, Consolas, monospace;
  user-select: all;
}

.identidad input:focus {
  outline: none;
  border-color: #0b2545;
  box-shadow: 0 0 0 2px rgba(11, 37, 69, 0.15);
}

/* ------------------ PREVIEW ------------------ */

.preview__head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.preview__acciones {
  display: flex;
  align-items: center;
  gap: 10px;
}

.preview__filtro {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: #475569;
}

.preview__filtro select {
  padding: 8px 10px;
  border: 1px solid #94a3b8;
  background: #fff;
  font-size: 13px;
  font-family: inherit;
  color: #1f2937;
  cursor: pointer;
}

.preview__filtro select:focus {
  outline: none;
  border-color: #0b2545;
  box-shadow: 0 0 0 2px rgba(11, 37, 69, 0.15);
}

.preview__note {
  font-size: 13px;
  color: #6b7280;
  font-style: italic;
  transition: color 0.15s ease;
}

.preview__note--loading {
  color: #0b2545;
  font-weight: 600;
  font-style: normal;
  background: #eef6ff;
  border-left: 4px solid #0b2545;
  padding: 8px 12px;
  margin: 8px 0;
}

.preview__note--error {
  color: #b91c1c;
  font-weight: 600;
  font-style: normal;
  background: #fef2f2;
  border-left: 4px solid #b91c1c;
  padding: 8px 12px;
  margin: 8px 0;
}

.preview__note--idle {
  color: #475569;
  font-style: normal;
  background: #f1f5f9;
  border-left: 4px solid #64748b;
  padding: 8px 12px;
  margin: 8px 0;
  font-weight: 500;
}

.preview__note--snapshot {
  color: #0b2545;
  font-style: normal;
  background: #e6f4ea;
  border-left: 4px solid #1f7a38;
  padding: 8px 12px;
  margin: 8px 0;
  font-weight: 500;
}

.preview__note--bloqueado {
  color: #3f3200;
  font-style: normal;
  background: #fff8e1;
  border-left: 4px solid #e0a800;
  padding: 8px 12px;
  margin: 8px 0;
  font-weight: 600;
}

.grid-entidades--bloqueada .entidad {
  cursor: not-allowed;
  opacity: 0.5;
  background: #f1f5f9;
  pointer-events: none;
}

.grid-entidades--bloqueada .entidad__count {
  color: #94a3b8;
  font-style: italic;
  font-size: 13px;
  font-weight: 500;
}

.grid-entidades--bloqueada .entidad__action {
  color: #b91c1c;
}

.grid-entidades--bloqueada .entidad__lupa {
  color: #b91c1c;
}

.spinner {
  display: inline-block;
  width: 12px;
  height: 12px;
  border: 2px solid #cbd5e1;
  border-top-color: #0b2545;
  border-radius: 50%;
  animation: spinner-rot 0.7s linear infinite;
  margin-right: 6px;
  vertical-align: -2px;
}

@keyframes spinner-rot {
  to { transform: rotate(360deg); }
}

.grid-entidades {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin: 16px 0;
}

.entidad {
  border: 1px solid #cbd5e1;
  background: #f8fafc;
  padding: 14px 16px;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.05s ease, box-shadow 0.15s ease;
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.entidad:hover {
  background: #e6f0fb;
  border-color: #0b2545;
  box-shadow: 0 2px 8px rgba(11, 37, 69, 0.12);
}

.entidad:hover .entidad__lupa {
  color: #0b2545;
  transform: scale(1.15);
}

.entidad:hover .entidad__action {
  color: #0b2545;
  text-decoration: underline;
}

.entidad:active {
  transform: translateY(1px);
}

.entidad__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.entidad__lupa {
  color: #64748b;
  transition: color 0.15s ease, transform 0.15s ease;
  flex-shrink: 0;
}

.entidad__action {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #64748b;
  font-weight: 600;
  text-align: right;
  transition: color 0.15s ease;
}

.entidad__nombre {
  font-size: 13px;
  color: #475569;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.entidad__count {
  font-size: 24px;
  font-weight: 800;
  color: #0b2545;
  font-variant-numeric: tabular-nums;
  display: block;
  line-height: 1.2;
}

.entidad__count--loading {
  color: #94a3b8;
  font-weight: 500;
  font-size: 13px;
  font-style: italic;
}

.preview__meta {
  display: flex;
  justify-content: space-between;
  padding: 10px 0 0;
  border-top: 1px solid #e5e7eb;
  font-size: 13px;
  color: #475569;
  margin-top: 10px;
}

/* ------------------ BOTONES ------------------ */

.btn {
  display: inline-block;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  padding: 10px 18px;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
  background: #0b2545;
  color: #fff;
}

.btn:hover:not(:disabled) {
  background: #13315c;
}

.btn:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.btn--ghost {
  background: #fff;
  color: #0b2545;
  border-color: #0b2545;
}

.btn--ghost:hover:not(:disabled) {
  background: #0b2545;
  color: #fff;
}

/* ------------------ DESCARGA ------------------ */

.botonera {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin: 14px 0 16px;
}

.btn--download {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 18px 14px;
  text-align: center;
  gap: 6px;
}

.btn__label {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.3px;
}

.btn__hint {
  font-size: 12px;
  font-weight: 400;
  opacity: 0.8;
}

.aviso {
  padding: 10px 14px;
  background: #fff4e5;
  border-left: 4px solid #e0a800;
  color: #3f3200;
  font-size: 13px;
  margin: 6px 0 0;
}

.aviso--ok {
  background: #e6f4ea;
  border-left-color: #1f7a38;
  color: #1f3d28;
}

/* ------------------ LOG DE DESCARGA ------------------ */

.card--log {
  border-color: #1f7a38;
  background: #f2faf4;
}

.card--log h2 {
  color: #1f7a38;
  border-bottom-color: #c6e6cf;
}

.log-tabla {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  margin-top: 8px;
}

.log-tabla td {
  padding: 8px 10px;
  border-bottom: 1px solid #c6e6cf;
}

.log-tabla td:first-child {
  font-weight: 600;
  color: #1f3d28;
  width: 38%;
  background: #e6f4ea;
}

.log-tabla td:last-child {
  color: #1f3d28;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  word-break: break-all;
}

.constancia-actions {
  margin-top: 22px;
  padding-top: 18px;
  border-top: 2px solid #c6e6cf;
}

.constancia-actions h3 {
  margin: 0 0 8px;
  font-size: 15px;
  color: #1f7a38;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.constancia-actions p {
  color: #1f3d28;
  margin: 0 0 12px;
}

.acciones-botonera {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 12px;
}

.const-hint {
  font-size: 12px;
  color: #475569;
  background: #f8fafc;
  padding: 10px 14px;
  border: 1px solid #e2e8f0;
  line-height: 1.8;
}

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: #0b2545;
  color: #fff;
  padding: 12px 22px;
  font-size: 14px;
  font-weight: 600;
  box-shadow: 0 4px 16px rgba(0,0,0,0.2);
  z-index: 9999;
  animation: toast-in 0.2s ease-out;
}

/* ------------------ MODAL DE PREVIEW ------------------ */

.modal {
  position: fixed;
  inset: 0;
  z-index: 9998;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal[hidden] {
  display: none;
}

.modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.72);
  backdrop-filter: blur(2px);
}

.modal__dialog {
  position: relative;
  background: #fff;
  border: 1px solid #cbd5e1;
  width: min(92vw, 1100px);
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 10px 40px rgba(0,0,0,0.3);
  animation: modal-in 0.15s ease-out;
}

@keyframes modal-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.modal__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 20px;
  background: #0b2545;
  color: #fff;
}

.modal__header h3 {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.modal__close {
  background: transparent;
  border: 0;
  color: #fff;
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
  padding: 0 6px;
}

.modal__close:hover {
  color: #cbd5e1;
}

.modal__sub {
  padding: 10px 20px;
  background: #eef2f7;
  border-bottom: 1px solid #e5e7eb;
  font-size: 13px;
  color: #475569;
}

.modal__body {
  overflow: auto;
  flex: 1;
}

.modal__tabla {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.modal__tabla thead th {
  background: #f1f5f9;
  color: #0b2545;
  padding: 8px 12px;
  text-align: left;
  font-weight: 700;
  border-bottom: 2px solid #cbd5e1;
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: 0.4px;
  position: sticky;
  top: 0;
  z-index: 1;
  white-space: nowrap;
}

.modal__tabla tbody td {
  padding: 6px 12px;
  border-bottom: 1px solid #e5e7eb;
  color: #1f2937;
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.modal__tabla tbody tr:nth-child(even) td {
  background: #fafafa;
}

.modal__tabla tbody tr:hover td {
  background: #fff8e1;
}

.modal__footer {
  padding: 10px 20px;
  background: #f8fafc;
  border-top: 1px solid #e5e7eb;
  font-size: 12px;
  color: #6b7280;
  font-style: italic;
}

.modal__loading {
  padding: 40px;
  text-align: center;
  color: #6b7280;
}

.modal__vacio {
  padding: 40px;
  text-align: center;
  color: #94a3b8;
  font-style: italic;
}

.modal__error {
  padding: 20px;
  color: #b91c1c;
  background: #fef2f2;
  border-left: 4px solid #b91c1c;
  margin: 16px;
  font-size: 13px;
}

@keyframes toast-in {
  from { opacity: 0; transform: translate(-50%, 8px); }
  to   { opacity: 1; transform: translate(-50%, 0); }
}

/* ------------------ FOOTER ------------------ */

.footer {
  background: #0b2545;
  color: #cbd5e1;
  padding: 20px 0;
  margin-top: 30px;
}

.footer__inner {
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
}

.footer__version {
  font-style: italic;
}

/* ------------------ RESPONSIVE ------------------ */

@media (max-width: 760px) {
  .identidad {
    grid-template-columns: 1fr;
  }
  .grid-entidades {
    grid-template-columns: repeat(2, 1fr);
  }
  .botonera {
    grid-template-columns: 1fr;
  }
  .topbar__inner {
    flex-direction: column;
    gap: 8px;
    align-items: flex-start;
  }
  .footer__inner {
    flex-direction: column;
    gap: 10px;
    align-items: flex-start;
  }
}
