/* Apto Laboral · sistema interno — el archivador de casos con lomos de color */
@font-face {
  font-family: "Montserrat";
  src: url("../fonts/Montserrat-latin-var.woff2") format("woff2");
  font-weight: 400 800;
  font-display: swap;
}

:root {
  --fondo: #eef6f7;
  --papel: #ffffff;
  --papel-2: #f7fbfb;
  --tinta: #1a2e52;
  --tinta-2: #44587a;
  --tinta-3: #5b6c84;
  --linea: #d6e2e6;
  --linea-2: #e7eef1;
  --accion: #0b7f8a;
  --accion-hondo: #0a6d77;
  --accion-suave: #def2f3;
  --debe: #a8590c;
  --debe-suave: #fdf1df;
  --error: #a63d2a;
  --error-suave: #fbe9e4;
  /* lomos (estados) */
  --plomo: #68737f;   --plomo-suave: #eceff2;
  --amarillo: #f2b33d; --amarillo-tinta: #3d2a00; --amarillo-suave: #fdf3d8;
  --verde: #27804a;   --verde-suave: #e1f2e7;
  --azul: #2f6fc0;    --azul-suave: #e2ecf8;
  --cancelado: #c3cad2; --cancelado-suave: #f1f3f5;
  --radio: 14px;
  --radio-ch: 9px;
  --sombra-hoja: 0 -12px 40px -16px rgba(26, 46, 82, 0.45);
  --sombra-boton: 0 10px 22px -10px rgba(10, 109, 119, 0.75);
  --ease-salida: cubic-bezier(0.16, 1, 0.3, 1);
  --nav-alto: 72px;
  --seguro-abajo: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100dvh;
  background: var(--fondo);
  color: var(--tinta);
  font-family: "Montserrat", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.45;
  font-weight: 500;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
::selection { background: var(--accion-suave); color: var(--tinta); }
img { max-width: 100%; height: auto; display: block; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accion-hondo); text-underline-offset: 3px; }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--accion) 55%, white); outline-offset: 2px; border-radius: 6px; }
.num { font-variant-numeric: tabular-nums; }
.oculto { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- barra de desplazamiento ---------- */
* { scrollbar-width: thin; scrollbar-color: #b9c8ce transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #b9c8ce; border-radius: 10px; border: 3px solid var(--fondo); }

/* ---------- iconos (SVG propios, trazo 2) ---------- */
.ic { width: 24px; height: 24px; flex: none; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.ic.ch { width: 20px; height: 20px; }

/* ---------- botones ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 18px; border-radius: 12px; border: 1px solid var(--linea);
  background: var(--papel); color: var(--tinta); font-weight: 700; font-size: 15px; cursor: pointer;
  transition: transform 120ms var(--ease-salida), background 160ms, border-color 160ms, box-shadow 160ms;
  text-decoration: none; white-space: nowrap;
}
.btn:active { transform: scale(0.97); }
.btn:hover { border-color: #b8cbd1; }
.btn.prim { background: var(--accion); border-color: var(--accion); color: #fff; }
.btn.prim:hover { background: var(--accion-hondo); border-color: var(--accion-hondo); }
.btn.wsp { background: #e4f5ea; border-color: #c4e6d0; color: #17603a; }
.btn.peligro { color: var(--error); }
.btn.ancho { width: 100%; }
.btn.ch { min-height: 40px; padding: 0 14px; font-size: 14px; border-radius: 10px; }
.btn:disabled, .btn[aria-disabled="true"] { opacity: 0.55; cursor: not-allowed; transform: none; }
.btn.cargando { color: transparent !important; position: relative; pointer-events: none; }
.btn.cargando::after {
  content: ""; position: absolute; width: 20px; height: 20px; border-radius: 50%;
  border: 2.5px solid rgba(255, 255, 255, 0.5); border-top-color: #fff; animation: girar 700ms linear infinite;
}
.btn:not(.prim).cargando::after { border-color: var(--linea); border-top-color: var(--accion); }
@keyframes girar { to { transform: rotate(360deg); } }
.enlace { background: none; border: 0; padding: 6px 2px; color: var(--accion-hondo); font-weight: 700; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }

/* ---------- formularios ---------- */
.campo { display: grid; gap: 6px; margin-bottom: 14px; }
.campo > span { font-size: 14px; font-weight: 700; color: var(--tinta-2); }
.campo small { font-size: 13px; color: var(--tinta-3); font-weight: 500; }
input[type="text"], input[type="email"], input[type="password"], input[type="tel"], input[type="number"],
input[type="date"], input[type="datetime-local"], input[type="search"], select, textarea {
  width: 100%; min-height: 48px; padding: 11px 14px; border-radius: 11px; border: 1.5px solid var(--linea);
  background: var(--papel); font-size: 16px; font-weight: 500; caret-color: var(--accion);
  transition: border-color 160ms, box-shadow 160ms;
}
textarea { min-height: 96px; resize: vertical; line-height: 1.45; }
input::placeholder, textarea::placeholder { color: #66758b; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accion); box-shadow: 0 0 0 3px var(--accion-suave); }
input[aria-invalid="true"] { border-color: var(--error); }
.fila2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.check { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border-radius: 12px; background: var(--papel-2); border: 1px solid var(--linea-2); font-size: 15px; cursor: pointer; }
.check input { width: 22px; height: 22px; margin: 1px 0 0; accent-color: var(--accion); flex: none; }
.opciones { display: flex; flex-wrap: wrap; gap: 8px; }
.opcion { position: relative; }
.opciones.filas { flex-direction: column; }
.opciones.filas .opcion span { width: 100%; min-height: 48px; padding: 8px 14px; }
.opcion input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.opcion span { display: inline-flex; align-items: center; min-height: 42px; padding: 0 14px; border-radius: 10px; border: 1.5px solid var(--linea); background: var(--papel); font-weight: 700; font-size: 14px; }
.opcion input:checked + span { border-color: var(--accion); background: var(--accion-suave); color: var(--accion-hondo); }
.opcion input:focus-visible + span { outline: 3px solid color-mix(in srgb, var(--accion) 55%, white); outline-offset: 2px; }
.error-form { color: var(--error); background: var(--error-suave); padding: 10px 12px; border-radius: 10px; font-size: 14px; font-weight: 600; margin: 0 0 12px; }

/* ---------- marco general ---------- */
.app { min-height: 100dvh; }
.principal { padding: 0 0 calc(var(--nav-alto) + 28px + var(--seguro-abajo)); }
.cabeza { padding: max(18px, env(safe-area-inset-top)) 18px 10px; display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; }
.cabeza h1 { font-size: 26px; line-height: 1.15; font-weight: 800; letter-spacing: -0.02em; margin: 0; text-wrap: balance; }
.cabeza .sub { font-size: 14px; font-weight: 600; color: var(--tinta-2); margin-top: 3px; }
.cabeza .acciones { display: flex; gap: 8px; }
.seccion { padding: 0 16px; margin-top: 22px; }
.seccion > h2 { font-size: 17px; font-weight: 800; margin: 0 2px 10px; display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.seccion > h2 .cuenta { font-size: 14px; font-weight: 700; color: var(--tinta-3); }
.vacio { text-align: center; padding: 34px 18px; color: var(--tinta-2); font-weight: 600; }
.vacio p { margin: 6px 0 14px; font-weight: 500; }
.aviso-demo { margin: 10px 16px 0; padding: 10px 14px; border-radius: 12px; background: var(--amarillo-suave); color: #5a3d00; font-size: 13.5px; font-weight: 600; display: flex; gap: 10px; align-items: center; justify-content: space-between; }

/* ---------- barra inferior (celular) con el botón + al centro ---------- */
.barra {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  height: calc(var(--nav-alto) + var(--seguro-abajo)); padding-bottom: var(--seguro-abajo);
  background: var(--papel); border-top: 1px solid var(--linea);
  display: grid; grid-template-columns: repeat(5, 1fr); align-items: start;
}
.barra a, .barra button.mas {
  display: flex; flex-direction: column; align-items: center; gap: 3px; padding-top: 11px; height: var(--nav-alto);
  font-size: 13px; font-weight: 700; color: var(--tinta-3); text-decoration: none; background: none; border: 0; cursor: pointer; position: relative;
}
.barra a[aria-current="page"] { color: var(--accion-hondo); }
.barra a[aria-current="page"]::before { content: ""; position: absolute; top: 0; left: 28%; right: 28%; height: 3px; border-radius: 0 0 3px 3px; background: var(--accion); }
.barra .insignia { position: absolute; top: 6px; left: calc(50% + 6px); min-width: 19px; height: 19px; padding: 0 5px; border-radius: 10px; background: var(--amarillo); color: var(--amarillo-tinta); font-size: 11px; font-weight: 800; display: grid; place-items: center; }
.boton-mas {
  justify-self: center; margin-top: -24px; width: 64px; height: 64px; border-radius: 50%; border: 4px solid var(--fondo);
  background: var(--accion); color: #fff; display: grid; place-items: center; box-shadow: var(--sombra-boton); cursor: pointer;
  transition: transform 160ms var(--ease-salida), background 160ms;
}
.boton-mas .ic { width: 30px; height: 30px; stroke-width: 2.6; }
.boton-mas:active { transform: scale(0.93); }
.boton-mas:hover { background: var(--accion-hondo); }

/* ---------- menú lateral (PC) ---------- */
.lateral { display: none; }

/* ---------- el archivador ---------- */
.buscar { padding: 4px 16px 0; }
.buscar label { position: relative; display: block; }
.buscar .ic { position: absolute; left: 14px; top: 12px; color: var(--tinta-3); }
.buscar input { padding-left: 46px; background: var(--papel); }
.pestanas { display: grid; grid-template-columns: repeat(4, 1fr); gap: 5px; padding: 14px 16px 0; align-items: end; }
.pestanas:not(.con-filtro) { align-items: stretch; }
.pestana {
  border: 0; cursor: pointer; border-radius: 12px 12px 0 0; padding: 8px 4px 9px; text-align: center;
  font-size: 13px; font-weight: 800; line-height: 1.15; color: #fff; min-height: 66px;
  transition: padding 220ms var(--ease-salida), filter 160ms; position: relative;
  display: flex; flex-direction: column; align-items: center; justify-content: flex-start;
}
.pestana b { display: block; font-size: 22px; font-weight: 800; line-height: 1.1; margin-bottom: 2px; font-variant-numeric: tabular-nums; }
.pestana[aria-pressed="true"], .pestanas:not(.con-filtro) .pestana { padding-top: 15px; padding-bottom: 12px; }
.pestana[aria-pressed="false"].hay-sel { filter: saturate(0.55) brightness(1.08); }
.pestana.e-registrado { background: var(--plomo); }
.pestana.e-con_especialista { background: var(--amarillo); color: var(--amarillo-tinta); }
.pestana.e-aprobado { background: var(--verde); }
.pestana.e-levantado { background: var(--azul); }
.pestana.salta b { animation: salto 420ms var(--ease-salida); }
@keyframes salto { 0% { transform: scale(1); } 35% { transform: scale(1.28); } 100% { transform: scale(1); } }

.cajon { background: var(--papel); margin: 0 16px; border-radius: 0 0 var(--radio) var(--radio); padding: 8px 8px 10px; border: 1px solid var(--linea); border-top: 0; }
.cajon.sin-pestanas { border-radius: var(--radio); border-top: 1px solid var(--linea); }
.cajon-pie { display: flex; justify-content: center; padding: 8px 4px 2px; }
.carpetas { display: grid; }
.carpetas .carpeta { background: var(--papel); border-color: var(--linea); }

.carpeta {
  display: flex; align-items: stretch; width: 100%; margin: 6px 0; text-align: left; cursor: pointer;
  border: 1px solid var(--linea-2); border-radius: 10px; overflow: hidden; background: var(--papel-2);
  text-decoration: none; color: inherit; transition: border-color 160ms, background 160ms, transform 120ms var(--ease-salida);
}
.carpeta:hover { border-color: #c3d4da; background: #fff; }
.carpeta:active { transform: scale(0.99); }
.carpeta[aria-current="true"] { border-color: var(--accion); background: #fff; box-shadow: 0 0 0 2px var(--accion-suave); }
.lomo { width: 32px; flex: none; position: relative; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.lomo span { writing-mode: vertical-rl; transform: rotate(180deg); font-size: 11px; font-weight: 800; letter-spacing: 0.06em; color: #fff; position: relative; z-index: 1; font-variant-numeric: tabular-nums; }
.lomo.e-registrado { background: var(--plomo); }
.lomo.e-con_especialista { background: var(--amarillo); }
.lomo.e-con_especialista span { color: var(--amarillo-tinta); }
.lomo.e-aprobado { background: var(--verde); }
.lomo.e-levantado { background: var(--azul); }
.lomo.e-cancelado { background: var(--cancelado); }
.lomo.e-cancelado span { color: #3c4652; }
/* firma: al cambiar de estado, el color nuevo sube por el lomo */
.repinta .lomo::before { content: ""; position: absolute; inset: 0; background: var(--lomo-antes, var(--plomo)); transform-origin: top; animation: barrido 620ms var(--ease-salida) forwards; }
@keyframes barrido { from { transform: scaleY(1); } to { transform: scaleY(0); } }
.carpeta .cuerpo { flex: 1; min-width: 0; padding: 10px 12px 11px; }
.carpeta .nombre { font-size: 16px; font-weight: 700; line-height: 1.3; overflow-wrap: anywhere; }
.carpeta.cancelada .nombre { text-decoration: line-through 2px var(--cancelado); color: var(--tinta-3); }
.carpeta .dato { font-size: 14px; font-weight: 500; color: var(--tinta-2); margin-top: 1px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.carpeta .paso { font-size: 13.5px; font-weight: 700; color: var(--accion-hondo); margin-top: 5px; display: flex; gap: 6px; align-items: center; min-width: 0; }
.carpeta .paso span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.carpeta .paso.alerta { color: var(--debe); }
.carpeta .paso.gris { color: var(--tinta-3); }
.carpeta .plata { padding: 10px 12px 10px 4px; text-align: right; font-size: 15px; font-weight: 800; color: var(--tinta-3); white-space: nowrap; font-variant-numeric: tabular-nums; }
.carpeta .plata.debe { color: var(--debe); }
.carpeta .plata.ok { color: var(--verde); font-size: 13px; font-weight: 700; }
.carpeta .plata small { display: block; font-size: 12.5px; font-weight: 700; color: var(--tinta-3); }

/* ---------- carpeta abierta (detalle) ---------- */
.detalle { padding-bottom: 20px; }
.tapa { position: relative; overflow: hidden; display: flex; align-items: center; gap: 12px; padding: max(14px, env(safe-area-inset-top)) 14px 14px; color: #fff; }
.tapa.e-registrado { background: var(--plomo); }
.tapa.e-con_especialista { background: var(--amarillo); color: var(--amarillo-tinta); }
.tapa.e-aprobado { background: var(--verde); }
.tapa.e-levantado { background: var(--azul); }
.tapa.e-cancelado { background: var(--cancelado); color: #2f3a46; }
.tapa.repinta::before { content: ""; position: absolute; inset: 0; background: var(--lomo-antes, var(--plomo)); transform-origin: top; animation: barrido 620ms var(--ease-salida) forwards; }
.tapa > * { position: relative; }
.tapa .volver { width: 44px; height: 44px; border-radius: 12px; border: 0; background: rgba(255, 255, 255, 0.22); color: inherit; display: grid; place-items: center; cursor: pointer; flex: none; }
.tapa .cod { font-size: 14px; font-weight: 800; letter-spacing: 0.06em; font-variant-numeric: tabular-nums; }
.tapa .est { font-size: 18px; font-weight: 800; line-height: 1.2; }
.tapa .ed { margin-left: auto; }
.tapa .ed .btn { background: rgba(255, 255, 255, 0.92); border-color: transparent; color: var(--tinta); }
.ficha { padding: 16px 18px 4px; }
.ficha h2 { font-size: 23px; font-weight: 800; letter-spacing: -0.015em; line-height: 1.2; margin: 0; overflow-wrap: anywhere; }
.ficha .linea-dato { color: var(--tinta-2); font-weight: 600; font-size: 15px; margin-top: 4px; }
.motivo { margin: 12px 0 0; padding: 12px 14px; border-radius: 12px; background: var(--papel); border: 1px solid var(--linea); font-size: 15px; line-height: 1.5; }
.motivo b { display: block; font-size: 12.5px; font-weight: 800; color: var(--tinta-3); margin-bottom: 2px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.chip { display: inline-flex; align-items: center; gap: 6px; min-height: 30px; padding: 0 10px; border-radius: 8px; background: var(--papel); border: 1px solid var(--linea); font-size: 13px; font-weight: 700; color: var(--tinta-2); }
.chip.ambar { background: var(--debe-suave); border-color: #f2d6ac; color: var(--debe); }
.chip.verde { background: var(--verde-suave); border-color: #bfe2cc; color: #1f6b3d; }

.siguiente { margin: 16px 16px 0; padding: 16px; border-radius: var(--radio); background: var(--papel); border: 1.5px solid var(--accion); }
.siguiente .paso-txt { font-size: 19px; font-weight: 800; line-height: 1.3; margin: 0 0 12px; text-wrap: balance; }
.siguiente .acc { display: grid; gap: 8px; }
.siguiente .acc-sec { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; }

.bloque { margin: 14px 16px 0; padding: 14px 16px; border-radius: var(--radio); background: var(--papel); border: 1px solid var(--linea); }
.bloque > h3 { font-size: 15px; font-weight: 800; margin: 0 0 10px; display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.fila-dato { display: flex; justify-content: space-between; gap: 12px; padding: 7px 0; border-top: 1px solid var(--linea-2); font-size: 15px; }
.fila-dato:first-of-type { border-top: 0; }
.fila-dato > span:first-child { color: var(--tinta-2); font-weight: 600; }
.fila-dato > span:last-child { font-weight: 700; text-align: right; font-variant-numeric: tabular-nums; }
.fila-dato.total > span { font-weight: 800; color: var(--tinta); }
.fila-dato.total.debe > span:last-child { color: var(--debe); }

/* recorrido del caso (como el seguimiento de un envío) */
.recorrido { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; }
.recorrido li { position: relative; padding-top: 18px; font-size: 13px; font-weight: 700; color: var(--tinta-3); line-height: 1.25; }
.recorrido li::before { content: ""; position: absolute; top: 4px; left: 0; right: 0; height: 6px; border-radius: 3px; background: var(--linea-2); }
.recorrido li.hecho::before { background: var(--c); }
.recorrido li.actual { color: var(--tinta); }
.recorrido li.actual::before { background: var(--c); box-shadow: 0 0 0 3px color-mix(in srgb, var(--c) 25%, white); }
.recorrido li small { display: block; font-weight: 600; font-size: 12.5px; color: var(--tinta-3); margin-top: 2px; }

.lista-simple { list-style: none; margin: 0; padding: 0; }
.lista-simple li { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-top: 1px solid var(--linea-2); font-size: 15px; }
.lista-simple li:first-child { border-top: 0; }
.lista-simple .crece { flex: 1; min-width: 0; }
.lista-simple .crece b { display: block; font-weight: 700; overflow-wrap: anywhere; }
.lista-simple .crece small { color: var(--tinta-3); font-weight: 600; font-size: 13px; }
.historial li { align-items: flex-start; }
.historial .punto { width: 10px; height: 10px; border-radius: 50%; background: var(--linea); margin-top: 6px; flex: none; }
.historial .punto.estado { background: var(--accion); }
.historial .punto.pago { background: var(--verde); }

/* ---------- filas de dinero / tablas ---------- */
.tabla { width: 100%; border-collapse: collapse; font-size: 14px; }
.tabla th { text-align: left; font-size: 12.5px; font-weight: 800; color: var(--tinta-3); padding: 8px 6px; border-bottom: 1.5px solid var(--linea); white-space: nowrap; }
.tabla td { padding: 10px 6px; border-bottom: 1px solid var(--linea-2); vertical-align: top; }
.tabla td.n, .tabla th.n { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tabla tfoot td { font-weight: 800; border-bottom: 0; border-top: 1.5px solid var(--linea); }
.envoltura-tabla { overflow-x: auto; margin: 0 -4px; }
.cuadre { margin: 0; padding: 6px 16px 10px; border-radius: var(--radio); background: var(--papel); border: 1px solid var(--linea); }
.cuadre .fila-dato { font-size: 16px; padding: 9px 0; }
.cuadre .fila-dato > span:last-child { font-weight: 800; }
.cuadre .fila-dato.menos > span:last-child { color: var(--debe); }
.cuadre .fila-dato.total { border-top: 3px double var(--tinta-2); margin-top: 4px; padding-top: 12px; }
.cuadre .fila-dato.total > span { font-size: 18px; font-weight: 800; }
.cuadre .fila-dato.total > span:last-child { color: var(--accion-hondo); font-size: 22px; }
.resumen-mes { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.cifra { padding: 12px 14px; border-radius: 12px; background: var(--papel-2); border: 1px solid var(--linea-2); }
.cifra span { display: block; font-size: 13px; font-weight: 700; color: var(--tinta-2); }
.cifra b { display: block; font-size: 21px; font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: -0.01em; margin-top: 2px; }
.cifra.final { grid-column: 1 / -1; background: var(--accion-suave); border-color: #bfe3e6; }
.cifra.final b { font-size: 26px; color: var(--accion-hondo); }
.cifra.debe b { color: var(--debe); }
.barras { display: grid; gap: 8px; }
.barra-h { display: grid; grid-template-columns: minmax(90px, 34%) 1fr 38px; gap: 10px; align-items: center; font-size: 14px; font-weight: 600; }
.barra-h .pista { height: 12px; border-radius: 6px; background: var(--linea-2); overflow: hidden; }
.barra-h .pista i { display: block; height: 100%; border-radius: 6px; background: var(--accion); transform-origin: left; animation: crecer 700ms var(--ease-salida) both; }
.barra-h b { text-align: right; font-variant-numeric: tabular-nums; }
@keyframes crecer { from { transform: scaleX(0); } }
.mes-sel { display: flex; align-items: center; gap: 6px; }
.mes-sel b { min-width: 132px; text-align: center; font-size: 15px; font-weight: 800; }
.mes-sel select { width: auto; min-width: 136px; }
.cabeza { flex-wrap: wrap; }
.reparto { margin-top: 10px; padding-top: 4px; border-top: 1.5px dashed var(--linea); }
@media (max-width: 699px) {
  .tabla.apilada thead { display: none; }
  .tabla.apilada, .tabla.apilada tbody, .tabla.apilada tfoot { display: block; }
  .tabla.apilada tr { display: grid; grid-template-columns: 1fr 1fr; gap: 2px 16px; padding: 10px 0; border-bottom: 1px solid var(--linea-2); }
  .tabla.apilada td { display: flex; justify-content: space-between; gap: 8px; border: 0; padding: 2px 0; }
  .tabla.apilada td:first-child { grid-column: 1 / -1; display: block; font-weight: 700; padding-bottom: 4px; }
  .tabla.apilada td[data-label]::before { content: attr(data-label); color: var(--tinta-3); font-weight: 600; font-size: 12.5px; }
  .tabla.apilada tfoot tr { border-bottom: 0; border-top: 1.5px solid var(--linea); }
  .tabla.apilada tfoot td { border-top: 0; }
}
.icono-btn { width: 44px; height: 44px; border-radius: 12px; border: 1px solid var(--linea); background: var(--papel); display: grid; place-items: center; cursor: pointer; color: var(--tinta); }
.icono-btn:hover { border-color: #b8cbd1; }

/* ---------- menú «Más» ---------- */
.menu-mas { display: grid; gap: 8px; padding: 0 16px; }
.menu-mas a, .menu-mas button { display: flex; align-items: center; gap: 14px; min-height: 58px; padding: 0 16px; border-radius: 14px; background: var(--papel); border: 1px solid var(--linea); font-weight: 700; font-size: 16px; text-decoration: none; color: var(--tinta); cursor: pointer; width: 100%; }
.menu-mas .ic { color: var(--accion-hondo); }
.menu-mas small { margin-left: auto; color: var(--tinta-3); font-weight: 600; font-size: 13px; }

/* ---------- hojas (diálogos) ---------- */
dialog.hoja {
  border: 0; padding: 0; margin: 0; max-width: none; width: 100%; max-height: 92dvh;
  position: fixed; inset: auto 0 0 0; border-radius: 22px 22px 0 0; background: var(--papel); color: var(--tinta);
  box-shadow: var(--sombra-hoja); overflow: hidden; display: flex; flex-direction: column;
}
dialog.hoja:not([open]) { display: none; }
dialog.hoja[open] { animation: subir 360ms var(--ease-salida); }
dialog.hoja::backdrop { background: rgba(16, 30, 54, 0.42); animation: aparecer 240ms ease-out; }
@keyframes subir { from { transform: translateY(100%); } }
@keyframes aparecer { from { opacity: 0; } }
.hoja-cab { display: flex; align-items: center; gap: 10px; padding: 10px 12px 10px 20px; border-bottom: 1px solid var(--linea-2); }
.hoja-cab::before { content: ""; position: absolute; top: 7px; left: 50%; width: 40px; height: 4px; margin-left: -20px; border-radius: 2px; background: var(--linea); }
.hoja-cab h2 { font-size: 18px; font-weight: 800; margin: 8px 0 0; flex: 1; line-height: 1.25; }
.hoja-cab .cerrar { width: 44px; height: 44px; border-radius: 12px; border: 0; background: var(--papel-2); display: grid; place-items: center; cursor: pointer; color: var(--tinta-2); margin-top: 6px; }
.hoja-cuerpo { padding: 16px 20px 8px; overflow-y: auto; overscroll-behavior: contain; }
.hoja-pie { padding: 12px 20px calc(14px + var(--seguro-abajo)); border-top: 1px solid var(--linea-2); display: flex; gap: 10px; background: var(--papel); }
.hoja-pie .btn { flex: 1; }
.pasos-envio { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.pasos-envio li { display: grid; grid-template-columns: 30px 1fr; gap: 10px; align-items: start; }
.pasos-envio .nro { width: 30px; height: 30px; border-radius: 50%; background: var(--accion-suave); color: var(--accion-hondo); font-weight: 800; display: grid; place-items: center; font-size: 14px; }
.pasos-envio li.listo .nro { background: var(--verde); color: #fff; }
.previa-msg { white-space: pre-wrap; font-size: 14px; background: var(--papel-2); border: 1px dashed var(--linea); border-radius: 10px; padding: 10px 12px; margin: 6px 0 8px; color: var(--tinta-2); }

/* lectura de hoja */
.subida { display: grid; gap: 10px; }
.zona-subir { display: flex; align-items: center; gap: 14px; padding: 16px; border-radius: 14px; border: 2px dashed #b7cdd3; background: var(--papel-2); cursor: pointer; font-weight: 700; }
.zona-subir:hover { border-color: var(--accion); }
.zona-subir .ic { width: 30px; height: 30px; color: var(--accion-hondo); }
.zona-subir small { display: block; font-weight: 500; color: var(--tinta-3); font-size: 13px; }
.leyendo { display: flex; gap: 12px; align-items: center; padding: 14px; border-radius: 12px; background: var(--accion-suave); font-weight: 700; color: var(--accion-hondo); }
.leyendo .rueda { width: 22px; height: 22px; border-radius: 50%; border: 3px solid #b9e1e4; border-top-color: var(--accion); animation: girar 800ms linear infinite; flex: none; }
.interconsulta { border: 1px solid var(--linea); border-radius: 14px; padding: 14px 14px 2px; margin-bottom: 12px; background: var(--papel); }
.interconsulta > h3 { font-size: 15px; font-weight: 800; margin: 0 0 10px; display: flex; justify-content: space-between; }
.nota-ia { font-size: 13px; font-weight: 600; color: var(--tinta-2); background: var(--amarillo-suave); padding: 8px 10px; border-radius: 9px; margin: 0 0 12px; }

/* ---------- avisos ---------- */
.avisos { position: fixed; left: 12px; right: 12px; bottom: calc(var(--nav-alto) + 16px + var(--seguro-abajo)); z-index: 60; display: grid; gap: 8px; pointer-events: none; }
.aviso { pointer-events: auto; justify-self: center; max-width: 520px; width: 100%; background: var(--tinta); color: #fff; border-radius: 12px; padding: 12px 16px; font-weight: 600; font-size: 15px; box-shadow: 0 14px 30px -14px rgba(16, 30, 54, 0.6); animation: subir-aviso 320ms var(--ease-salida); display: flex; align-items: center; gap: 10px; }
.aviso.error { background: var(--error); }
@keyframes subir-aviso { from { transform: translateY(16px); opacity: 0; } }

/* ---------- acceso ---------- */
.acceso { min-height: 100dvh; display: grid; place-items: center; padding: 24px 18px; }
.acceso-caja { width: 100%; max-width: 400px; }
.acceso-caja .logo { width: 220px; margin: 0 auto 26px; }
.acceso-caja form { background: var(--papel); border: 1px solid var(--linea); border-radius: 18px; padding: 22px 20px 8px; }
.acceso-caja h1 { font-size: 20px; font-weight: 800; margin: 0 0 16px; }
.acceso-pie { text-align: center; font-size: 13px; color: var(--tinta-3); margin-top: 18px; font-weight: 600; }
.acceso-pie a { color: var(--tinta-2); }
.roles-demo { display: grid; gap: 8px; margin-top: 14px; }

/* ---------- inactividad ---------- */
dialog.pausa { border: 0; padding: 20px; margin: 0; width: 100%; height: 100%; max-width: none; max-height: none; background: transparent; place-items: center; }
dialog.pausa[open] { display: grid; }
dialog.pausa::backdrop { background: rgba(238, 246, 247, 0.96); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); }
.pausa-caja { background: var(--papel); border: 1px solid var(--linea); border-radius: 18px; padding: 24px 22px; max-width: 360px; width: 100%; text-align: center; box-shadow: 0 20px 50px -24px rgba(16, 30, 54, 0.5); }
.pausa-caja h2 { margin: 0 0 6px; font-size: 20px; font-weight: 800; }
.pausa-caja p { margin: 0 0 16px; color: var(--tinta-2); }

/* ---------- PC: menú lateral, archivador al centro y carpeta abierta a la derecha ---------- */
@media (min-width: 1024px) {
  .barra { display: none; }
  .app { display: grid; grid-template-columns: 252px 1fr; }
  .lateral {
    display: flex; flex-direction: column; position: sticky; top: 0; height: 100dvh; padding: 24px 14px 18px; overflow-y: auto;
    background: var(--papel); border-right: 1px solid var(--linea);
  }
  .lateral .logo { width: 196px; margin: 4px 10px 26px; }
  .lateral .nuevo { margin: 0 4px 18px; min-height: 52px; font-size: 16px; }
  .lateral nav { display: grid; gap: 2px; }
  .lateral nav a { display: flex; align-items: center; gap: 12px; min-height: 46px; padding: 0 12px; border-radius: 11px; color: var(--tinta-2); font-weight: 700; text-decoration: none; font-size: 15px; }
  .lateral nav a:hover { background: var(--papel-2); color: var(--tinta); }
  .lateral nav a[aria-current="page"] { background: var(--accion-suave); color: var(--accion-hondo); }
  .lateral nav a .insignia { margin-left: auto; min-width: 22px; height: 22px; padding: 0 6px; border-radius: 11px; background: var(--amarillo); color: var(--amarillo-tinta); font-size: 12px; font-weight: 800; display: grid; place-items: center; }
  .lateral .usuario { margin-top: auto; padding: 12px; border-radius: 12px; background: var(--papel-2); font-size: 14px; }
  .lateral .usuario b { display: block; }
  .lateral .usuario small { color: var(--tinta-3); font-weight: 600; }
  .lateral .credito { font-size: 12px; color: var(--tinta-3); margin: 12px 12px 0; font-weight: 600; }
  .lateral .credito a { color: var(--tinta-3); }
  .principal { padding: 10px 0 40px; min-width: 0; }
  .cabeza { padding: 18px 28px 12px; }
  .cabeza h1 { font-size: 30px; }
  .seccion { padding: 0 28px; }
  .buscar { padding: 4px 28px 0; }
  .pestanas { padding: 16px 28px 0; }
  .cajon { margin: 0 28px; }
  .aviso-demo { margin: 10px 28px 0; }
  .menu-mas { padding: 0 28px; max-width: 720px; }
  .avisos { bottom: 24px; left: 276px; }
  .dos-paneles { display: grid; grid-template-columns: minmax(380px, 470px) 1fr; align-items: start; }
  .dos-paneles > .panel-detalle { position: sticky; top: 0; height: 100dvh; overflow-y: auto; border-left: 1px solid var(--linea); background: var(--fondo); }
  .dos-paneles .cajon, .dos-paneles .pestanas, .dos-paneles .buscar { margin-left: 0; margin-right: 0; padding-left: 0; padding-right: 0; }
  .dos-paneles > div:first-child { padding: 0 20px 0 28px; }
  .dos-paneles > div:first-child .cabeza { padding-left: 0; padding-right: 0; }
  .dos-paneles > div:first-child .aviso-demo { margin-left: 0; margin-right: 0; }
  .panel-vacio { height: 100%; display: grid; place-items: center; color: var(--tinta-3); font-weight: 600; text-align: center; padding: 40px; }
  .panel-vacio .lomos-deco { display: flex; gap: 6px; justify-content: center; margin-bottom: 16px; }
  .panel-vacio .lomos-deco i { width: 18px; height: 74px; border-radius: 4px; }
  .detalle .tapa .volver { display: none; }
  .detalle .tapa { padding-top: 18px; }
  .ancho-lectura { max-width: 860px; }
  dialog.hoja { inset: 0; margin: auto; width: min(600px, calc(100vw - 48px)); max-height: min(86dvh, 860px); border-radius: 20px; height: fit-content; }
  dialog.hoja[open] { animation: aparecer-dlg 260ms var(--ease-salida); }
  .hoja-cab::before { display: none; }
  .hoja-cab h2 { margin-top: 0; }
  .hoja-cab .cerrar { margin-top: 0; }
  .pestana { font-size: 14px; }
  .cuadre { max-width: 620px; }
}
@keyframes aparecer-dlg { from { opacity: 0; transform: translateY(14px) scale(0.98); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; animation-iteration-count: 1 !important; transition-duration: 1ms !important; }
}
