/* Visor de documentos de Agencia Rueda. Mismo aspecto que el tablero de tareas y el planner (rojo de la agencia #ff0000).
   Sin fuentes ni recursos externos. Sin estilos en línea: la CSP solo deja los de /static, así que todo va por clases. */

:root {
  --bg: #f6f6f4;
  --surface: #ffffff;
  --surface-2: #f0efec;
  --borde: #e3e1dc;
  --borde-fuerte: #cdcac3;
  --texto: #1d1d1b;
  --suave: #6b6a66;
  --acento: #ff0000;
  --acento-tinta: #ffffff;
  --acento-suave: #ffe5e5;
  --enlace: #1b4f91;
  --peligro: #c62828;
  --sombra: 0 1px 2px rgba(0, 0, 0, .05), 0 4px 16px rgba(0, 0, 0, .06);
  --sombra-fuerte: 0 8px 40px rgba(0, 0, 0, .22);
  --radio: 10px;
  --radio-sm: 6px;
  --alto-barra: 56px;
  --ancho-lateral: 320px;
  --ancho-lectura: 760px;

  --fuente: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif;
  --fuente-codigo: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", monospace;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--texto); font: 15px/1.5 var(--fuente); -webkit-font-smoothing: antialiased; }
h1, h2, h3, p, dl, dd { margin: 0; }
h1 { font-size: 24px; line-height: 1.2; font-weight: 700; letter-spacing: -.01em; }
h2 { font-size: 18px; line-height: 1.25; }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid #2f6fed; outline-offset: 2px; border-radius: 4px; }
[hidden] { display: none !important; }

.suave { color: var(--suave); }
.chico { font-size: 13px; }
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.carga-inicial { padding: 40px 16px; text-align: center; color: var(--suave); }
.error { color: var(--peligro); font-size: 13px; }
.ico { flex: none; vertical-align: -3px; }

/* Saltar la barra y la lista de archivos: solo aparece cuando recibe el foco con el teclado. */
.saltar { position: absolute; left: 8px; top: -60px; z-index: 100; padding: 8px 14px; background: var(--texto); color: #fff; border: 0; border-radius: var(--radio-sm); }
.saltar:focus { top: 8px; }

/* ---------- botones y campos ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 38px; padding: 6px 14px; border: 1px solid var(--borde-fuerte); background: var(--surface); border-radius: var(--radio-sm); white-space: nowrap; font-weight: 500; text-decoration: none; }
.btn:hover:not(:disabled) { background: var(--surface-2); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.grande { min-height: 52px; padding: 10px 22px; font-size: 17px; font-weight: 600; border-radius: var(--radio); }
.btn.primario { background: var(--acento); border-color: var(--acento); color: var(--acento-tinta); }
.btn.primario:hover:not(:disabled) { background: #d90000; }
.btn.fantasma { border-color: transparent; background: none; }
.btn.fantasma:hover:not(:disabled) { background: var(--surface-2); }
.icono-btn { display: inline-grid; place-items: center; min-width: 38px; min-height: 38px; border: 0; background: none; border-radius: var(--radio-sm); color: var(--texto); }
.icono-btn:hover { background: var(--surface-2); }

.campo-input { width: 100%; min-height: 38px; border: 1px solid var(--borde-fuerte); background: var(--surface); border-radius: var(--radio-sm); padding: 7px 10px; }
.campo-input:focus { outline: none; border-color: var(--texto); box-shadow: 0 0 0 3px rgba(29, 29, 27, .15); }
.buscador { position: relative; display: flex; align-items: center; flex: 1 1 260px; min-width: 0; }
.buscador > .ico { position: absolute; left: 11px; color: var(--suave); pointer-events: none; }
.buscador .campo-input { padding-left: 34px; }
.marcar { display: inline-flex; align-items: center; gap: 8px; min-height: 38px; font-weight: 500; cursor: pointer; white-space: nowrap; }
.marcar input { width: 18px; height: 18px; accent-color: var(--acento); }

/* ---------- páginas sueltas (ingreso, errores) ---------- */
.centro { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px; padding: 24px 16px; }
.tarjeta-centro { width: min(420px, 100%); background: var(--surface); border: 1px solid var(--borde); border-radius: 16px; box-shadow: var(--sombra); padding: 36px 28px; display: flex; flex-direction: column; align-items: center; gap: 14px; text-align: center; }
.logo { flex: none; width: 52px; height: 52px; border-radius: 14px; background: var(--acento); color: #fff; display: grid; place-items: center; font-size: 26px; font-weight: 800; }
.marca-texto { font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--suave); }
.aviso-login { background: #fbf0c7; color: #7a5b00; padding: 8px 12px; border-radius: var(--radio-sm); font-size: 14px; }
.tarjeta-centro .btn.grande { width: 100%; }
.aviso-suave { background: var(--surface); border: 1px solid var(--borde-fuerte); padding: 10px 14px; border-radius: var(--radio); font-size: 14px; margin-bottom: 12px; }

/* ---------- barra de arriba ---------- */
.barra-sup { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between; gap: 12px; height: var(--alto-barra); padding: 0 16px; background: var(--surface); border-bottom: 1px solid var(--borde); }
.barra-izq { display: flex; align-items: center; gap: 12px; min-width: 0; }
.barra-izq .logo { width: 34px; height: 34px; border-radius: 9px; font-size: 18px; }
.titulo-barra { display: flex; flex-direction: column; gap: 0; line-height: 1.15; }
.titulo-barra h1 { font-size: 18px; }
.titulo-barra .marca-texto { font-size: 10.5px; }
.barra-der { display: flex; align-items: center; gap: 6px; flex: none; }
.nombre-cliente { font-size: 18px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.abrir-lateral { display: none; }

/* ---------- inicio ---------- */
.inicio { max-width: 1100px; margin: 0 auto; padding: 24px 20px 48px; }
.filtros-inicio { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 20px; margin-bottom: 8px; }
.filtros-inicio .buscador { max-width: 460px; }
.cuenta-clientes { margin: 4px 0 14px; min-height: 20px; }
.tarjetas { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 12px; }
.grupo-areas { margin-top: 28px; }
.grupo-areas:empty { margin-top: 0; }
.grupo-titulo { margin-bottom: 12px; font-size: 16px; color: var(--suave); }
.tarjeta-cliente { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 64px; padding: 12px 16px; background: var(--surface); border: 1px solid var(--borde); border-left: 4px solid var(--acento); border-radius: 8px; box-shadow: var(--sombra); text-decoration: none; font-weight: 600; overflow-wrap: anywhere; }
.tarjeta-cliente:hover { border-color: var(--borde-fuerte); border-left-color: var(--acento); background: #fffafa; }
.pastilla { flex: none; display: inline-flex; align-items: center; padding: 1px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--acento-suave); color: #9b0000; }
.estado-caja { display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 28px 20px; text-align: center; }
.estado-caja.grande { padding: 64px 20px; }
.estado-caja h2, .estado-caja p { max-width: 100%; overflow-wrap: anywhere; }
.estado-caja.descarga .ico { color: var(--suave); }

/* ---------- cliente: columna de archivos + documento ---------- */
.cuerpo-visor { display: grid; grid-template-columns: var(--ancho-lateral) minmax(0, 1fr); align-items: start; }
.lateral { position: sticky; top: var(--alto-barra); height: calc(100vh - var(--alto-barra)); height: calc(100dvh - var(--alto-barra)); display: flex; flex-direction: column; gap: 8px; padding: 12px 8px 0 12px; background: var(--surface); border-right: 1px solid var(--borde); }
.lateral-cab { display: flex; align-items: center; justify-content: space-between; gap: 4px; padding-left: 4px; }
.lateral-titulo { font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--suave); }
.lateral-cab .icono-btn { margin-left: auto; min-width: 32px; min-height: 32px; }
.lateral-cab .icono-btn + .icono-btn { margin-left: 0; }
.cerrar-lateral { display: none; }
.lateral .buscador { flex: none; margin-right: 4px; }
.estado-filtro { padding-left: 4px; }
.estado-filtro:empty { display: none; }
.lista-archivos { flex: 1; min-height: 0; overflow: auto; padding-bottom: 24px; overscroll-behavior: contain; }
.lista-archivos .cargando { padding: 24px 8px; }
.sin-archivos { padding: 12px 6px; }
.fondo-lateral { display: none; }

.arbol, .nivel, .resultados { list-style: none; margin: 0; padding: 0; }
.fila { display: flex; align-items: center; min-height: 32px; margin-right: 4px; border-radius: 6px; }
.fila:hover { background: var(--surface-2); }
.fila.actual { background: var(--acento-suave); }
.fila.actual .nombre { font-weight: 600; }
.n0 { padding-left: 2px; } .n1 { padding-left: 16px; } .n2 { padding-left: 30px; } .n3 { padding-left: 44px; } .n4 { padding-left: 58px; }
.n5 { padding-left: 72px; } .n6 { padding-left: 86px; } .n7 { padding-left: 100px; } .n8 { padding-left: 114px; } .n9 { padding-left: 128px; }
.chevron { flex: none; display: inline-grid; place-items: center; width: 22px; height: 28px; padding: 0; border: 0; background: none; color: var(--suave); border-radius: 4px; }
.chevron .ico { transition: transform .12s; vertical-align: 0; }
.chevron.abierto .ico { transform: rotate(90deg); }
.chevron.vacio { cursor: default; }
.nombre { flex: 1; min-width: 0; display: flex; align-items: center; gap: 7px; min-height: 32px; padding: 3px 6px 3px 2px; border: 0; background: none; text-align: left; text-decoration: none; font-size: 14px; line-height: 1.3; border-radius: 6px; }
.nombre .ico { color: var(--suave); }
.nombre-texto { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.resultado { display: flex; align-items: flex-start; gap: 8px; padding: 6px 8px; margin-right: 4px; border-radius: 6px; text-decoration: none; font-size: 14px; line-height: 1.3; }
.resultado .ico { margin-top: 2px; color: var(--suave); }
.resultado:hover { background: var(--surface-2); }
.resultado.actual { background: var(--acento-suave); font-weight: 600; }
.res-textos { display: flex; flex-direction: column; min-width: 0; }
.res-nombre { overflow-wrap: anywhere; }
.res-carpeta { font-size: 12px; font-weight: 400; overflow-wrap: anywhere; }

/* ---------- el documento ---------- */
.contenido { min-width: 0; padding: 20px 28px 64px; outline: none; }
.cab-doc { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px 16px; max-width: 1000px; margin-bottom: 14px; }
/* Un nombre de carpeta o de archivo larguísimo y sin espacios se parte en vez de ensanchar la página (en el celular no hay scroll horizontal). */
.migas { min-width: 0; max-width: 100%; }
.migas ol { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 0; list-style: none; margin: 0; padding: 0; font-size: 13px; color: var(--suave); }
.migas li { min-width: 0; overflow-wrap: anywhere; }
.migas li + li::before { content: "›"; margin: 0 7px; color: var(--borde-fuerte); }
.migas a { color: var(--suave); }
.migas a:hover { color: var(--texto); }
.migas li[aria-current="page"] { color: var(--texto); font-weight: 600; overflow-wrap: anywhere; }
.acciones-doc { display: flex; flex-wrap: wrap; gap: 8px; }
.acciones-doc .btn { min-height: 34px; padding: 4px 12px; font-size: 14px; }
.cuerpo-doc { max-width: 1000px; }
.cargando { display: flex; align-items: center; justify-content: center; gap: 10px; padding: 48px 16px; color: var(--suave); }
.rueda { width: 18px; height: 18px; border: 3px solid var(--borde-fuerte); border-top-color: var(--acento); border-radius: 50%; animation: giro .8s linear infinite; }
@keyframes giro { to { transform: rotate(360deg); } }

.centrado { display: flex; justify-content: center; padding: 8px 0; }
.vista-img { max-width: 100%; height: auto; background: repeating-conic-gradient(#f0efec 0% 25%, #fff 0% 50%) 50% / 16px 16px; border: 1px solid var(--borde); border-radius: 6px; }
.medio { width: 100%; max-height: 78vh; background: #000; border-radius: 8px; }
audio.medio { background: none; }
.marco { display: block; width: 100%; height: calc(100vh - 190px); height: calc(100dvh - 190px); min-height: 480px; border: 1px solid var(--borde); border-radius: 8px; background: #fff; }
pre.texto { margin: 0; padding: 16px 18px; overflow: auto; max-height: calc(100dvh - 190px); background: var(--surface); border: 1px solid var(--borde); border-radius: 8px; font: 13px/1.55 var(--fuente-codigo); tab-size: 4; white-space: pre; }

/* Lectura de un documento Markdown: un renglón cómodo (~760 px), tablas y código que se desplazan adentro de su caja. */
.doc { background: var(--surface); border: 1px solid var(--borde); border-radius: 12px; padding: 32px 44px 40px; font-size: 16.5px; line-height: 1.7; overflow-wrap: break-word; hyphens: manual; }
.doc > * { max-width: var(--ancho-lectura); }
.doc > .tabla { max-width: 100%; }
.doc > :first-child { margin-top: 0; }
.doc > :last-child { margin-bottom: 0; }
.doc h1, .doc h2, .doc h3, .doc h4, .doc h5, .doc h6 { margin: 1.7em 0 .55em; line-height: 1.28; font-weight: 700; letter-spacing: -.005em; scroll-margin-top: calc(var(--alto-barra) + 16px); }
.doc h1 { font-size: 1.85em; margin-top: 0; letter-spacing: -.015em; }
.doc h2 { font-size: 1.45em; padding-bottom: .25em; border-bottom: 1px solid var(--borde); }
.doc h3 { font-size: 1.2em; }
.doc h4 { font-size: 1.02em; }
.doc h5 { font-size: .92em; text-transform: uppercase; letter-spacing: .04em; color: var(--suave); }
.doc h6 { font-size: .88em; color: var(--suave); }
.doc p, .doc ul, .doc ol, .doc blockquote, .doc pre, .doc .tabla { margin: 0 0 1em; }
.doc ul, .doc ol { padding-left: 1.6em; }
.doc li { margin: .2em 0; }
.doc li > p { margin: .35em 0; }
.doc li > ul, .doc li > ol { margin: .2em 0 .2em; }
.doc li.tarea { list-style: none; margin-left: -1.35em; }
.doc .casilla { margin: 0 .5em 0 0; width: 1em; height: 1em; vertical-align: -.1em; accent-color: var(--acento); }
.doc a { color: var(--enlace); text-decoration: underline; text-underline-offset: 2px; text-decoration-thickness: 1px; }
.doc a:hover { text-decoration-thickness: 2px; }
.doc .roto { color: var(--suave); border-bottom: 1px dashed var(--peligro); cursor: help; }
.doc strong, .doc b { font-weight: 650; }
.doc hr { max-width: var(--ancho-lectura); margin: 2em 0; border: 0; border-top: 1px solid var(--borde-fuerte); }
.doc blockquote { padding: .25em 1em; border-left: 4px solid var(--borde-fuerte); color: #4a4945; background: #fbfaf8; border-radius: 0 6px 6px 0; }
.doc blockquote > :last-child { margin-bottom: 0; }
.doc blockquote > :first-child { margin-top: 0; }
/* La línea de «Copia literal de Notion · Página original · Creada...» que sigue al título, como una barra de datos. */
.doc h1 + blockquote { padding: 8px 12px; border-left: 0; background: var(--surface-2); color: var(--suave); font-size: .82em; line-height: 1.5; border-radius: 8px; }
.doc h1 + blockquote img { height: 1.3em; width: auto; vertical-align: -.3em; }
.doc code { padding: .1em .35em; border-radius: 4px; background: var(--surface-2); font: .88em var(--fuente-codigo); overflow-wrap: anywhere; }
.doc pre { padding: 14px 16px; overflow: auto; background: #f4f3f0; border: 1px solid var(--borde); border-radius: 8px; font-size: 14px; line-height: 1.55; tab-size: 4; }
.doc pre code { padding: 0; background: none; font-size: 1em; overflow-wrap: normal; }
.doc img { max-width: 100%; height: auto; vertical-align: middle; border-radius: 4px; }
.doc p > img:only-child { display: block; margin: .4em 0; }
.doc sub, .doc sup { line-height: 0; }
.doc .tabla { overflow-x: auto; border: 1px solid var(--borde); border-radius: 8px; -webkit-overflow-scrolling: touch; }
.doc table { width: 100%; border-collapse: collapse; font-size: .92em; line-height: 1.5; }
.doc th, .doc td { padding: 8px 12px; border-bottom: 1px solid var(--borde); border-right: 1px solid var(--borde); vertical-align: top; text-align: left; min-width: 6ch; }
.doc th:last-child, .doc td:last-child { border-right: 0; }
.doc tbody tr:last-child td { border-bottom: 0; }
.doc thead th { background: var(--surface-2); font-weight: 650; border-bottom: 1px solid var(--borde-fuerte); }
.doc tbody tr:nth-child(even) td { background: #fbfaf8; }
.doc .al-cen { text-align: center; }
.doc .al-der { text-align: right; }
.doc .al-izq { text-align: left; }

/* ---------- aviso flotante ---------- */
.toast { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 1000; display: flex; align-items: center; gap: 14px; background: var(--texto); color: #fff; padding: 11px 18px; border-radius: 10px; box-shadow: var(--sombra-fuerte); max-width: calc(100vw - 24px); }
.toast-error { background: var(--peligro); }

/* ---------- celular y pantallas angostas: la lista de archivos es un cajón que se abre con «Archivos» ---------- */
@media (max-width: 799px) {
  .barra-sup { padding: 0 8px; gap: 6px; }
  .barra-izq { gap: 4px; flex: 1; }
  .nombre-cliente { font-size: 16px; }
  .quien, .texto-salir { display: none; }
  .barra-der { gap: 0; }
  .btn.volver { padding: 6px 8px; }
  .abrir-lateral { display: inline-flex; }
  .cerrar-lateral { display: inline-grid; }
  .inicio { padding: 16px 12px 40px; }
  .cuerpo-visor { display: block; }
  .lateral { position: fixed; z-index: 40; top: 0; left: 0; bottom: 0; width: min(340px, 88vw); height: 100vh; height: 100dvh; padding-top: 10px; border-right: 0; box-shadow: var(--sombra-fuerte); transform: translateX(-104%); visibility: hidden; transition: transform .18s ease-out, visibility 0s linear .18s; }
  .con-lateral .lateral { transform: none; visibility: visible; transition-delay: 0s; }
  .con-lateral .fondo-lateral { display: block; position: fixed; inset: 0; z-index: 30; background: rgba(20, 20, 18, .45); }
  .contenido { padding: 12px 10px 48px; }
  .cab-doc { margin-bottom: 10px; }
  .doc { padding: 20px 16px 28px; border-radius: 10px; font-size: 16px; }
  .doc ul, .doc ol { padding-left: 1.4em; }
  .marco { height: calc(100vh - 220px); height: calc(100dvh - 220px); min-height: 360px; }
}

/* En el iPhone, Safari agranda la página al tocar un campo con letra de menos de 16 px y la deja descentrada. */
@media (max-width: 799px), (pointer: coarse) {
  .campo-input { font-size: 16px; }
}

@media (prefers-reduced-motion: reduce) {
  .lateral { transition: none; }
  .chevron .ico { transition: none; }
  .rueda { animation-duration: 2s; }
}
