/* Acordis — hoja compartida de la aplicación.
   La cargan el panel (index.html), las páginas públicas (solicitud, firma,
   acuse, constancia, aviso), los impresos y la plataforma interna.
   Sistema "Tinta notarial": ver DESIGN.md en la raíz del repo.

   Reglas que esta hoja fija para todos:
   - Un solo juego de tokens. Ningún archivo vuelve a declarar :root.
   - Seis tamaños de texto (--t-*). Si un tamaño no está aquí, no existe.
   - Tres botones: .btn (primario), .btn--secondary, .btn--quiet. Una
     acción primaria por vista.
   - El radio dice el material: papel 2px, controles 8px, tarjetas 10px,
     sellos 2px.
   - El foco siempre se ve. Nadie pone outline: none. */

:root {
  --paper: #f2f0e9;
  --paper-deep: #e8e5d8;
  --surface: #fcfbf7;
  --line: #ddd9ca;
  --line-soft: #e7e4d8;
  --ink: #1e241d;
  --ink-soft: #5b6353;
  /* 4.65:1 sobre --paper. Sirve para texto informativo pequeño; el valor
     anterior (#8b927f, 3.1:1) solo servía para decoración. */
  --ink-faint: #676e5b;
  --brand: #1e5b45;
  --brand-deep: #123c2c;
  --brand-tint: #e6efe4;
  --brand-line: #b9d1bd;
  --cobre: #a05c22;
  --cobre-tint: #f4e7d3;
  --cobre-line: #dcbf9b;
  --ok: #1e6e3f;
  --ok-tint: #ddefdd;
  --ok-line: #a9d4ae;
  --warn: #8a5a10;
  --warn-tint: #f4e8cf;
  --warn-line: #dcc389;
  --err: #ab3226;
  --err-tint: #f6e0da;
  --err-line: #e4b1a7;
  --btn-ink: #fdfcf3;

  /* Alias de compatibilidad: el panel los usaba sin haberlos definido. */
  --card: var(--surface);
  --gray: var(--ink-faint);

  --radius: 8px;          /* controles */
  --radius-card: 10px;    /* tarjetas y paneles */
  --radius-paper: 2px;    /* hojas y sellos */
  --shadow-1: 0 1px 2px rgba(30, 36, 29, .06);
  --shadow-2: 0 10px 28px -14px rgba(30, 36, 29, .28);
  --doc-shadow: rgba(30, 36, 29, .3);
  --doc-edge: rgba(30, 36, 29, .09);
  --velo: rgba(18, 60, 44, .38);

  --font-ui: 'Public Sans', ui-sans-serif, system-ui, sans-serif;
  --font-display: 'Fraunces', Georgia, serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, Consolas, monospace;

  /* Escala tipográfica. Seis pasos y nada más. */
  --t-xs: .72rem;    /* sellos, folios, etiquetas mono */
  --t-sm: .8rem;     /* meta, ayudas, pies */
  --t-md: .9rem;     /* cuerpo de interfaz */
  --t-lg: 1.05rem;   /* títulos de tarjeta y de sección */
  --t-xl: 1.55rem;   /* título de vista */
  --t-num: 2rem;     /* la cifra que importa */

  --btn-h: 40px;
  --btn-h-sm: 32px;
  --input-h: 44px;
}

/* ── Base ─────────────────────────────────────────────────────────────── */
* { box-sizing: border-box; }
html, body { margin: 0; }
/* El atributo hidden y la clase .hidden ganan siempre. */
[hidden], .hidden { display: none !important; }
body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: var(--t-md);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { margin: 0; }
button, input, select, textarea { font-family: inherit; }
button { cursor: pointer; }
a { color: inherit; -webkit-tap-highlight-color: transparent; }
.mono { font-family: var(--font-mono); }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
:is(button, a, input, select, textarea, summary, canvas, [tabindex]):focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto !important; }
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* ── Marca ────────────────────────────────────────────────────────────── */
.wordmark {
  font-family: var(--font-display); font-variation-settings: "opsz" 30;
  font-weight: 600; font-size: 1.45rem; letter-spacing: -.01em; line-height: 1;
  color: var(--ink); text-decoration: none;
}
.wordmark i, .wordmark em { font-style: italic; color: var(--brand); }

/* Membrete de la inmobiliaria: logo si lo subió, si no el nombre. Es lo
   primero que ve el inquilino en cualquier página pública. */
.membrete {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px 20px; flex-wrap: wrap; margin-bottom: 22px;
}
.membrete__marca { display: flex; align-items: center; gap: 12px; min-width: 0; }
.membrete__logo { display: block; max-height: 44px; max-width: 180px; object-fit: contain; }
.membrete__nombre {
  font-family: var(--font-display); font-variation-settings: "opsz" 24;
  font-weight: 600; font-size: 1.2rem; line-height: 1.15; letter-spacing: -.01em;
}
.membrete__sub {
  display: block; font-family: var(--font-mono); font-size: var(--t-xs);
  letter-spacing: .06em; text-transform: uppercase; color: var(--ink-faint); margin-top: 3px;
}
.membrete__meta { font-family: var(--font-mono); font-size: var(--t-xs); color: var(--ink-faint); text-align: right; }

/* Pie de página pública: quién lo hace posible y a quién escribir. */
.pie-acordis {
  margin-top: 40px; padding-top: 16px; border-top: 1px solid var(--line);
  display: flex; justify-content: space-between; align-items: center; gap: 8px 20px; flex-wrap: wrap;
  font-size: var(--t-sm); color: var(--ink-faint);
}
.pie-acordis .wordmark { font-size: 1.05rem; color: var(--ink-soft); }
.pie-acordis a { color: var(--ink-soft); }

/* ── Botones ──────────────────────────────────────────────────────────── */
.btn, .btn-primary,
.btn--secondary, .btn-secondary,
.btn--quiet, .btn-quiet {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-family: var(--font-ui); font-weight: 600; font-size: .88rem; line-height: 1.2;
  min-height: var(--btn-h); padding: 0 18px; border-radius: var(--radius);
  border: 1px solid transparent; text-decoration: none; cursor: pointer;
  white-space: nowrap;
  transition: background .15s ease, border-color .15s ease, color .15s ease;
}
.btn, .btn-primary { background: var(--brand); border-color: var(--brand); color: var(--btn-ink); }
.btn:hover, .btn-primary:hover { background: var(--brand-deep); border-color: var(--brand-deep); }
.btn--secondary, .btn-secondary { background: transparent; border-color: var(--line); color: var(--ink); font-weight: 500; }
.btn--secondary:hover, .btn-secondary:hover { border-color: var(--brand); background: var(--brand-tint); color: var(--ink); }
.btn--quiet, .btn-quiet {
  background: transparent; border-color: transparent; color: var(--brand-deep);
  min-height: var(--btn-h-sm); padding: 0 8px; font-size: var(--t-sm);
  text-decoration: underline; text-underline-offset: 3px;
}
.btn--quiet:hover, .btn-quiet:hover { background: var(--brand-tint); }
.btn--small { min-height: var(--btn-h-sm); padding: 0 12px; font-size: var(--t-sm); }
.btn--block { width: 100%; }
.btn--danger:hover, .btn-secondary.danger:hover { border-color: var(--err); color: var(--err); background: var(--err-tint); }
/* Deshabilitado se ve deshabilitado. En firma.html el botón bloqueado era
   idéntico al activo y el usuario tocaba sin que pasara nada. */
:is(.btn, .btn-primary, .btn--secondary, .btn-secondary, .btn--quiet, .btn-quiet):is(:disabled, [aria-disabled="true"]) {
  opacity: .45; cursor: not-allowed; pointer-events: auto;
}
:is(.btn, .btn-primary):is(:disabled, [aria-disabled="true"]):hover { background: var(--brand); border-color: var(--brand); }

/* ── Sellos ───────────────────────────────────────────────────────────── */
/* Rectangular, mono, mayúsculas, borde y tinte: el sello de estatus del
   sistema. 11.5px mínimo; a 9.6px era la etiqueta más frecuente del panel y
   la menos legible. */
.sello {
  display: inline-flex; align-items: center; gap: 5px;
  font-family: var(--font-mono); font-size: var(--t-xs); font-weight: 600;
  line-height: 1.2; letter-spacing: .08em; text-transform: uppercase;
  padding: 3px 7px; border: 1px solid var(--brand-line); border-radius: var(--radius-paper);
  background: var(--brand-tint); color: var(--brand-deep); white-space: nowrap; vertical-align: middle;
}
.sello--ok { background: var(--ok-tint); border-color: var(--ok-line); color: var(--ok); }
.sello--warn { background: var(--warn-tint); border-color: var(--warn-line); color: var(--warn); }
.sello--err { background: var(--err-tint); border-color: var(--err-line); color: var(--err); }
.sello--cobre { background: var(--cobre-tint); border-color: var(--cobre-line); color: var(--cobre); }
.sello--soft { background: var(--paper); border-color: var(--line); color: var(--ink-soft); }
.sello--solido { background: var(--err); border-color: var(--err); color: #fff; }
.sello--punteado { border-style: dashed; background: transparent; }
/* La estampa: el sello grande de un documento (Firmado, Sin firmas, Pagado,
   Borrador). Sin tinte de fondo, borde grueso, ligeramente girado. */
.sello--estampa {
  flex-direction: column; gap: 2px; background: transparent;
  border-width: 2px; border-color: currentColor; color: var(--brand);
  font-size: .8rem; padding: 7px 12px 6px; letter-spacing: .12em;
  transform: rotate(-6deg);
}
.sello--estampa small { font-size: .58rem; font-weight: 500; letter-spacing: .06em; }
.sello--estampa.sello--soft { color: var(--ink-faint); }
.sello--estampa.sello--warn { color: var(--warn); }
.sello--estampa.sello--err { color: var(--err); }
.sello--estampa.sello--cobre { color: var(--cobre); }
.sello--estampa.sello--ok { color: var(--ok); }

/* ── Tarjetas, avisos y estados ───────────────────────────────────────── */
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-card);
  padding: 22px 24px; margin-bottom: 16px; box-shadow: var(--shadow-1);
}
.card__titulo { font-size: var(--t-lg); font-weight: 700; margin-bottom: 4px; }
.card__sub { font-size: var(--t-sm); color: var(--ink-soft); margin-bottom: 14px; }

.aviso {
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--paper);
  padding: 13px 16px; font-size: var(--t-md); color: var(--ink); margin-bottom: 16px;
}
.aviso--ok { background: var(--ok-tint); border-color: var(--ok-line); color: var(--ok); }
.aviso--warn { background: var(--warn-tint); border-color: var(--warn-line); color: var(--warn); }
.aviso--err { background: var(--err-tint); border-color: var(--err-line); color: var(--err); }
.aviso--brand { background: var(--brand-tint); border-color: var(--brand-line); color: var(--brand-deep); }

/* Estado vacío: invita a actuar y trae la acción adentro. */
.vacio {
  padding: 28px 20px; border: 1px dashed var(--line); border-radius: var(--radius-card);
  text-align: center; color: var(--ink-soft); font-size: var(--t-md);
}
.vacio .btn, .vacio .btn-primary, .vacio .btn--secondary { margin-top: 12px; }
.estado { text-align: center; color: var(--ink-soft); padding: 48px 20px; font-size: var(--t-md); }
.estado--err { color: var(--err); }

/* Pantalla de éxito: check dibujado, título y qué sigue. */
.exito { text-align: center; padding: 8px 4px 4px; }
.exito__check {
  width: 60px; height: 60px; border-radius: 50%; margin: 0 auto 16px;
  background: var(--ok-tint); border: 1.5px solid var(--ok);
  display: flex; align-items: center; justify-content: center;
}
.exito__check svg { width: 30px; height: 30px; }
.exito__check svg path {
  stroke: var(--ok); stroke-width: 2.4; fill: none; stroke-linecap: round; stroke-linejoin: round;
  stroke-dasharray: 24; stroke-dashoffset: 24;
  animation: exitoCheck .5s .15s ease forwards;
}
@keyframes exitoCheck { to { stroke-dashoffset: 0; } }
@media (prefers-reduced-motion: reduce) { .exito__check svg path { animation: none; stroke-dashoffset: 0; } }
.exito__titulo { font-family: var(--font-display); font-variation-settings: "opsz" 30; font-weight: 600; font-size: 1.45rem; margin-bottom: 8px; }
.exito__texto { color: var(--ink-soft); max-width: 44ch; margin: 0 auto; }
.exito__pasos { list-style: none; margin: 22px 0 0; padding: 0; text-align: left; border-top: 1px solid var(--line); }
.exito__pasos li {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 12px 0; border-bottom: 1px solid var(--line);
}
.exito__pasos li span { font-size: var(--t-md); }

/* Guía de pasos numerados para flujos públicos (solicitud, firma). */
.num-paso {
  display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0;
  width: 24px; height: 24px; border-radius: var(--radius-paper);
  background: var(--brand); color: var(--btn-ink);
  font-family: var(--font-mono); font-size: var(--t-xs); font-weight: 600;
}
.num-paso--hecho { background: var(--ok); }
.num-paso--pendiente { background: var(--paper-deep); color: var(--ink-faint); }
.titulo-paso { display: flex; align-items: center; gap: 10px; font-size: var(--t-lg); font-weight: 700; margin-bottom: 4px; }

/* ── Campos ───────────────────────────────────────────────────────────── */
.campo { margin-bottom: 14px; }
.campo > label, .campo > legend { display: block; font-size: var(--t-sm); font-weight: 600; color: var(--ink-soft); margin-bottom: 6px; }
.campo :is(input, select, textarea),
.input {
  width: 100%; min-height: var(--input-h); padding: 10px 12px;
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--paper); color: var(--ink); font-size: 1rem; font-family: var(--font-ui);
}
.campo textarea { min-height: 72px; resize: vertical; }
.campo :is(input, select, textarea):focus, .input:focus {
  border-color: var(--brand); background: var(--surface);
  box-shadow: 0 0 0 3px var(--brand-tint);
}
/* El anillo de teclado se pega al borde del campo: el halo de tinte ya da
   el aire. Nunca outline: none. */
.campo :is(input, select, textarea):focus-visible, .input:focus-visible { outline-offset: 0; }
.campo [aria-invalid="true"] { border-color: var(--err); }
.campo__ayuda { font-size: var(--t-sm); color: var(--ink-soft); margin-top: 5px; }
.campo__ayuda--err { color: var(--err); font-weight: 600; }
.campo-fila { display: flex; gap: 12px; flex-wrap: wrap; }
.campo-fila .campo { flex: 1 1 200px; min-width: 0; }
.opcion-check { display: flex; align-items: flex-start; gap: 10px; }
.opcion-check input { width: 20px; height: 20px; flex-shrink: 0; margin-top: 2px; accent-color: var(--brand); }

/* ── Toasts ───────────────────────────────────────────────────────────── */
#toast-zone, .toast-zone {
  position: fixed; right: 16px; bottom: 16px; left: 16px; z-index: 200;
  display: flex; flex-direction: column; gap: 8px; align-items: flex-end;
  pointer-events: none;
}
.toast {
  pointer-events: auto;
  background: var(--ink); color: var(--paper);
  border-radius: var(--radius); padding: 11px 16px;
  font-size: var(--t-sm); font-weight: 500;
  box-shadow: var(--shadow-2);
  display: flex; align-items: center; gap: 8px;
  animation: toastIn .25s ease;
  max-width: min(360px, 100%);
}
.toast.ok::before, .toast--ok::before { content: "✓"; color: var(--brand-line); font-weight: 700; }
.toast.err, .toast--err { background: var(--err); color: #fff; }
.toast.err::before, .toast--err::before { content: "!"; font-weight: 700; }
@keyframes toastIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.toast.saliendo { opacity: 0; transition: opacity .3s ease; }

/* ── Puerta de sesión (impresos y páginas que exigen panel) ───────────── */
.puerta { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.puerta__card {
  width: 100%; max-width: 360px; text-align: center;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-card);
  padding: 32px 28px; box-shadow: var(--shadow-2);
}
.puerta__card h1 { font-family: var(--font-display); font-variation-settings: "opsz" 24; font-weight: 600; font-size: 1.3rem; margin-bottom: 8px; }
.puerta__card p { font-size: var(--t-md); color: var(--ink-soft); margin: 0 0 18px; }

/* ── Lienzo de firma ──────────────────────────────────────────────────── */
/* Una caja de papel con línea base y la cruz notarial: se entiende "aquí
   firmas" sin leer nada. Misma caja en firma.html y acuse.html. */
.lienzo-firma { position: relative; }
.lienzo-firma canvas {
  width: 100%; height: 200px; display: block;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-paper);
  touch-action: none; cursor: crosshair;
}
.lienzo-firma::before {
  content: ""; position: absolute; left: 24px; right: 24px; bottom: 44px; height: 1px;
  background: var(--line); pointer-events: none;
}
.lienzo-firma::after {
  content: "×"; position: absolute; left: 12px; bottom: 30px;
  font-family: var(--font-mono); font-size: 1.1rem; color: var(--ink-faint); pointer-events: none;
}
.lienzo-firma__acciones { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-top: 8px; font-size: var(--t-sm); color: var(--ink-soft); }
