/* SINFRA · marco (entrada, inicio de sesión, barra, menú) y componentes compartidos.
   «Cuadrado y filoso»: sin sombras, sin degradados, sin esquinas redondeadas (chips 2 px). */

/* ======================= Entrada (una vez por sesión) ======================= */
.entrada {
  position: fixed; inset: 0; z-index: 50;
  background: var(--barra);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 24px;
  transition: opacity .18s ease-out;
}
.entrada.saliendo { opacity: 0; pointer-events: none; }
.entrada-marca { width: 72px; height: 72px; background: var(--acento); animation: entrada-marca .35s cubic-bezier(.2, .8, .2, 1) both; }
.entrada-nombre { font-size: 56px; line-height: 56px; font-weight: 800; letter-spacing: -0.02em; color: var(--papel); }
.entrada-nombre span { display: inline-block; animation: entrada-letra .35s cubic-bezier(.2, .8, .2, 1) both; }
.entrada-nombre span:nth-child(1) { animation-delay: .10s; }
.entrada-nombre span:nth-child(2) { animation-delay: .14s; }
.entrada-nombre span:nth-child(3) { animation-delay: .18s; }
.entrada-nombre span:nth-child(4) { animation-delay: .22s; }
.entrada-nombre span:nth-child(5) { animation-delay: .26s; }
.entrada-nombre span:nth-child(6) { animation-delay: .30s; }
.entrada-logo { width: 190px; height: auto; animation: entrada-letra .35s cubic-bezier(.2, .8, .2, 1) .4s both; }
.entrada-barra { width: 200px; height: 2px; background: var(--barra-borde); }
.entrada-barra div { height: 2px; background: var(--acento); transform-origin: left; animation: entrada-barra 1s ease-out both; }
@keyframes entrada-marca { from { transform: scale(.3) rotate(-45deg); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes entrada-letra { from { transform: translateY(18px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes entrada-barra { from { transform: scaleX(0); } to { transform: scaleX(1); } }

/* ======================= Inicio de sesión ======================= */
.login {
  min-height: 100vh; background: var(--barra);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 32px; padding: 32px 16px;
}
.login-marca, .barra-marca { display: flex; align-items: center; gap: 16px; color: var(--papel); text-decoration: none; }
.login-marca img { width: 160px; height: auto; }
.divisoria { width: 1px; height: 24px; background: var(--barra-linea); }
.login-nombre { font-size: 22px; font-weight: 800; letter-spacing: .02em; }
.login-caja { width: 100%; max-width: 400px; background: var(--papel); padding: 32px; display: flex; flex-direction: column; gap: 16px; }
.login-caja h1 { font-size: 24px; }
.login-bajada { margin-top: -8px; }
.login-nota { font-size: 13px; color: var(--gris); }

/* ======================= Barra superior ======================= */
.barra {
  position: sticky; top: 0; z-index: 20;
  height: var(--alto-barra); background: var(--barra); color: var(--papel);
  display: flex; align-items: center; gap: 16px; padding: 0 24px;
}
.barra :focus-visible { outline-color: var(--papel); }
.barra-marca img { width: 138px; height: auto; }
.barra-nombre { font-size: 18px; font-weight: 800; letter-spacing: .02em; }
.barra-marca:hover { color: var(--papel); }
.barra-menu { display: none; width: 44px; height: 44px; background: transparent; color: var(--papel); border: 1px solid var(--barra-borde); align-items: center; justify-content: center; }
.barra-usuario { margin-left: auto; display: flex; align-items: center; gap: 12px; min-width: 0; }
.avatar { width: 32px; height: 32px; flex: none; background: var(--acento); color: var(--papel); font-size: 13px; font-weight: 700; display: flex; align-items: center; justify-content: center; }
.barra-usuario-nombre { font-size: 13px; color: var(--barra-texto-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ======================= Menú lateral ======================= */
.cuerpo { position: relative; display: flex; min-height: calc(100vh - var(--alto-barra)); }
/* El fondo del menú llega hasta el final de la página (el menú mismo queda fijo, del alto de la ventana). */
.cuerpo::before {
  content: ""; position: absolute; top: 0; bottom: 0; left: 0; width: var(--ancho-menu);
  background: var(--papel-2); border-right: 1px solid var(--linea); pointer-events: none;
}
body.menu-plegado .cuerpo::before { width: var(--ancho-menu-plegado); }
.lateral {
  flex: none; width: var(--ancho-menu); background: var(--papel-2); border-right: 1px solid var(--linea);
  position: sticky; top: var(--alto-barra); height: calc(100vh - var(--alto-barra)); overflow-y: auto;
  display: flex; flex-direction: column; gap: 16px; padding: 16px 12px;
}
.menu-plegar {
  align-self: flex-start; width: 44px; height: 44px; flex: none;
  background: var(--papel-2); color: var(--tinta); border: 1px solid var(--linea);
  display: flex; align-items: center; justify-content: center;
}
.menu-plegar:hover { background: var(--papel); }
.lateral-lista { list-style: none; display: flex; flex-direction: column; gap: 4px; }
.lateral a, .lateral-salir {
  display: flex; align-items: center; gap: 12px; min-height: 44px; padding: 10px 12px; width: 100%;
  font-size: 14px; font-weight: 500; color: var(--tinta); text-decoration: none; background: transparent; border: 0; text-align: left;
}
.lateral a svg, .lateral-salir svg { flex: none; }
.lateral a:hover, .lateral-salir:hover { background: var(--papel); color: var(--tinta); }
.lateral a.activo { background: var(--acento); color: var(--papel); font-weight: 700; }
.lateral a:focus-visible, .lateral-salir:focus-visible { outline-offset: -2px; }
.lateral a.activo:focus-visible { outline-color: var(--tinta); }
.lateral-pie { margin-top: auto; display: flex; flex-direction: column; gap: 4px; border-top: 1px solid var(--linea); padding-top: 12px; }
.lateral-pie a, .lateral-salir { font-size: 13px; color: var(--grafito); }

/* Menú contraído (computador): solo íconos; el nombre queda para el lector de pantalla y como ayuda (title). */
body.menu-plegado .lateral { width: var(--ancho-menu-plegado); padding: 16px 12px; }
body.menu-plegado .lateral-texto { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
body.menu-plegado .lateral a, body.menu-plegado .lateral-salir { justify-content: center; padding: 10px 0; }

.contenido { flex: 1; min-width: 0; padding: 32px; view-transition-name: contenido; }
.pantalla { display: flex; flex-direction: column; gap: 24px; }
::view-transition-old(contenido), ::view-transition-new(contenido) { animation-duration: .16s; }

/* Celular: el menú se abre con ☰ sobre un velo. */
.velo-menu { position: fixed; inset: var(--alto-barra) 0 0 0; z-index: 30; background: var(--velo); }
@media (max-width: 760px) {
  .cuerpo::before { display: none; }
  .barra { padding: 0 12px; gap: 12px; }
  .barra-menu { display: flex; }
  .barra-marca { gap: 10px; }
  .barra-marca img { width: 104px; }
  .barra-nombre { font-size: 16px; }
  .barra-usuario-nombre { display: none; }
  .lateral, body.menu-plegado .lateral {
    position: fixed; z-index: 40; top: var(--alto-barra); left: 0; bottom: 0; height: auto;
    width: min(300px, 86vw); padding: 16px 12px;
    transform: translateX(-100%); visibility: hidden; transition: transform .18s ease-out, visibility 0s linear .18s;
  }
  body.menu-abierto { overflow: hidden; }
  body.menu-abierto .lateral { transform: none; visibility: visible; transition: transform .18s ease-out; }
  body.menu-plegado .lateral-texto { position: static; width: auto; height: auto; overflow: visible; clip-path: none; }
  body.menu-plegado .lateral a, body.menu-plegado .lateral-salir { justify-content: flex-start; padding: 10px 12px; }
  .contenido { padding: 20px 16px 32px; }
}

/* ======================= Encabezado de cada pantalla ======================= */
.encabezado { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px; }
.encabezado-textos { min-width: 0; }
.antetitulo { font-size: 12px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: var(--acento); }
.encabezado h1 { margin-top: 4px; font-size: 32px; line-height: 38px; font-weight: 700; letter-spacing: -0.01em; }
.bajada { margin-top: 4px; font-size: 15px; color: var(--grafito); }
@media (max-width: 760px) { .encabezado h1 { font-size: 26px; line-height: 32px; } }

/* ======================= Botones ======================= */
.boton {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 10px 16px;
  font-size: 14px; font-weight: 700; line-height: 1.2; text-decoration: none; text-align: center;
  background: var(--papel); color: var(--tinta); border: 1px solid var(--tinta); border-radius: var(--radio);
}
.boton:hover { background: var(--papel-2); color: var(--tinta); }
.boton.principal { min-height: 52px; padding: 14px 20px; background: var(--acento); color: var(--papel); border-color: var(--acento); }
.boton.principal:hover { background: var(--acento-oscuro); border-color: var(--acento-oscuro); color: var(--papel); }
.boton.oscuro { background: var(--tinta); color: var(--papel); border-color: var(--tinta); }
.boton.oscuro:hover { background: var(--grafito); color: var(--papel); }
.boton.enlace { min-height: 44px; padding: 10px 4px; background: transparent; border-color: transparent; text-decoration: underline; font-weight: 600; }
.boton.enlace:hover { background: transparent; color: var(--grafito); }
.boton.icono { width: 44px; min-width: 44px; padding: 0; }
.boton.peligro { color: var(--rojo-texto); border-color: var(--rojo-texto); }
.boton.enlace.peligro { border-color: transparent; }
.boton.ancho { width: 100%; }
.boton:disabled, .boton[aria-disabled="true"] { background: var(--papel-2); color: var(--gris); border-color: var(--linea); }
.acciones { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }

/* ======================= Campos ======================= */
.campo-caja { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.campo-caja > label { font-size: 13px; font-weight: 600; color: var(--tinta); }
.campo {
  width: 100%; min-height: 44px; padding: 10px 12px;
  font-size: 14px; background: var(--papel); color: var(--tinta);
  border: 1px solid var(--gris); border-radius: var(--radio);
}
textarea.campo { min-height: 88px; resize: vertical; line-height: 1.45; }
.campo:focus, .campo:focus-visible { outline: 2px solid var(--acento); outline-offset: -1px; }
.campo[aria-invalid="true"] { border-color: var(--rojo-texto); }
.campo:disabled, .campo[readonly] { background: var(--papel-2); color: var(--grafito); }
.ayuda { font-size: 12px; color: var(--gris); }
.ayuda:empty { display: none; }
.error-campo { font-size: 12px; font-weight: 600; color: var(--rojo-texto); }
.fila-campos { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
@media (max-width: 760px) { .fila-campos { grid-template-columns: 1fr; } }

/* ======================= Tarjetas, tablas y chips ======================= */
.tarjeta { background: var(--papel); border: 1px solid var(--linea); padding: 24px; }
.tabla-caja { position: relative; overflow-x: auto; border: 1px solid var(--linea); -webkit-overflow-scrolling: touch; }
.tabla-caja:focus-visible { outline-offset: -2px; }
table.tabla { width: 100%; border-collapse: collapse; }
.tabla th {
  font-size: 11px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: var(--gris);
  text-align: left; padding: 10px 12px; background: var(--papel-2); border-bottom: 1px solid var(--linea); white-space: nowrap;
}
.tabla td { padding: 14px 12px; border-bottom: 1px solid var(--linea); font-size: 14px; vertical-align: top; }
.tabla tbody tr:last-child td { border-bottom: 0; }
.tabla th.num, .tabla td.num { text-align: right; }

.chip {
  display: inline-block; padding: 3px 8px; font-size: 12px; font-weight: 700; line-height: 1.4; white-space: nowrap;
  border: 1px solid var(--linea); border-radius: var(--radio-chip); background: var(--papel-2); color: var(--tinta);
}
.chip.estado-borrador { background: var(--acento-claro); color: var(--acento); border-color: var(--acento-claro); }
.chip.estado-enviada { background: var(--papel); color: var(--tinta); border-color: var(--tinta); }
.chip.estado-por_entregar { background: var(--acento); color: var(--papel); border-color: var(--acento); }
.chip.estado-entregado { background: var(--tinta); color: var(--papel); border-color: var(--tinta); }
.chip.estado-cerrado { background: var(--papel-2); color: var(--tinta); border-color: var(--papel-2); }
.chip.estado-rechazado { background: var(--papel); color: var(--gris); border: 1px dashed var(--gris); }

/* ======================= Avisos en recuadro ======================= */
.caja-aviso { padding: 12px 16px; font-size: 14px; border: 1px solid var(--linea); background: var(--papel-2); color: var(--tinta); display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.caja-aviso p { color: inherit; flex: 1 1 240px; }
.caja-aviso.error { background: var(--luz); color: var(--rojo-texto); border-color: var(--luz); font-weight: 600; }
.caja-aviso.advertencia { background: var(--ambar); color: var(--ambar-texto); border-color: var(--ambar); }
.caja-aviso.info { background: var(--acento-claro); color: var(--tinta); border-color: var(--acento-claro); }
.caja-aviso.exito { background: var(--papel-2); color: var(--tinta); border-color: var(--linea); }

/* ======================= Esqueleto ======================= */
.esqueleto-grupo { display: flex; flex-direction: column; gap: 12px; }
.esqueleto { background: var(--papel-2); animation: pulso .9s ease-in-out calc(var(--i, 0) * .1s) infinite alternate; }
@keyframes pulso { from { opacity: .45; } to { opacity: 1; } }
.esqueleto-tarjetas { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 16px; }
.esq-tarjeta { height: 104px; }
.esq-cabeza { height: 36px; }
.esq-fila { height: 52px; }
.esq-campo { display: flex; flex-direction: column; gap: 6px; }
.esq-etiqueta { height: 14px; width: 30%; }
.esq-input { height: 44px; }
.esq-titulo { height: 32px; width: 50%; }
.esq-linea { height: 20px; }

/* ======================= Notas plegadas ======================= */
.nota { font-size: 13px; color: var(--grafito); }
.nota > summary { display: inline-flex; align-items: center; min-height: 44px; font-weight: 700; color: var(--tinta); cursor: pointer; }
.nota-cuerpo { max-width: 760px; display: flex; flex-direction: column; gap: 8px; padding-bottom: 8px; }
.nota-cuerpo p { line-height: 20px; }

/* ======================= Selector segmentado ======================= */
.segmentado { display: flex; flex-wrap: wrap; gap: 8px; }
.segmentado button {
  min-height: 44px; padding: 10px 14px; font-size: 13px; font-weight: 600; white-space: nowrap;
  background: var(--papel); color: var(--tinta); border: 1px solid var(--gris); border-radius: var(--radio);
}
.segmentado button:hover { background: var(--papel-2); }
.segmentado button[aria-pressed="true"] { background: var(--tinta); color: var(--papel); border-color: var(--tinta); font-weight: 700; }

/* ======================= Vacío ======================= */
.vacio { padding: 40px 16px; text-align: center; color: var(--grafito); border: 1px dashed var(--linea); }

/* ======================= Ventanas ======================= */
.dialogo {
  margin: auto; width: min(520px, calc(100vw - 32px)); max-height: calc(100vh - 32px); overflow: auto;
  padding: 24px; border: 1px solid var(--tinta); border-radius: var(--radio); background: var(--papel); color: var(--tinta);
}
.dialogo::backdrop { background: var(--velo); }
.dialogo-cabeza { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.dialogo-titulo { font-size: 20px; padding-top: 8px; }
.dialogo-cuerpo { display: flex; flex-direction: column; gap: 16px; margin-top: 12px; }
.dialogo-acciones { justify-content: flex-end; margin-top: 24px; }
@media (max-width: 760px) { .dialogo { padding: 20px 16px; } .dialogo-acciones .boton { flex: 1 1 auto; } }

/* ======================= Avisos (toasts) ======================= */
.avisos { position: fixed; right: 24px; bottom: 24px; z-index: 60; display: flex; flex-direction: column; gap: 8px; width: min(420px, calc(100vw - 32px)); pointer-events: none; }
.aviso { pointer-events: auto; display: flex; gap: 12px; align-items: flex-start; padding: 12px 16px; font-size: 14px; font-weight: 500; line-height: 1.4; border: 1px solid transparent; }
.aviso span { flex: 1; padding-top: 2px; }
.aviso-exito { background: var(--tinta); color: var(--papel); }
.aviso-advertencia { background: var(--ambar); color: var(--ambar-texto); border-color: var(--ambar-texto); }
.aviso-error { background: var(--luz); color: var(--rojo-texto); border-color: var(--rojo-texto); }
.aviso-cerrar { flex: none; width: 44px; height: 44px; margin: -12px -14px -12px 0; display: flex; align-items: center; justify-content: center; background: transparent; border: 0; color: inherit; }
@media (max-width: 760px) { .avisos { right: 16px; bottom: 16px; } }
