/* MindSign Docs · sistema visual de las pantallas.
   Derivado de docs/marca.html: índigo para la acción, tinta para el texto,
   verde sello SOLO para «firmado». Plus Jakarta Sans + JetBrains Mono. */

:root {
  --bg: #F6F7FB; --paper: #FFFFFF; --ink: #1E1B4B; --text: #2B2A45; --muted: #5F5F7A; --line: #E2E3EB;
  --brand: #4F46E5; --brand-hover: #4338CA; --brand-tint: #EEF0FE; --on-brand: #FFFFFF;
  --seal: #1F8A5B; --seal-tint: #E7F5EE;
  --alert: #B42323; --alert-tint: #FCEDED; --warn: #8A5A00; --warn-tint: #FDF3DC;
  --neutral-tint: #F0F1F5; --focus: #4F46E5; --shadow: 0 1px 2px rgba(30, 27, 75, .06), 0 4px 16px rgba(30, 27, 75, .05);
  --f: "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, Menlo, Consolas, monospace;
  --r: 14px; --r-sm: 10px;
  --empresa: #4F46E5; --empresa-hover: #4338CA;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0E0D24; --paper: #16153A; --ink: #ECEBFF; --text: #D6D5F0; --muted: #A3A4C6; --line: #2A2856;
    --brand: #8B8FF0; --brand-hover: #A5ABF8; --brand-tint: #232161; --on-brand: #0E0D24;
    --seal: #4FCB8E; --seal-tint: #123526;
    --alert: #FF8A8A; --alert-tint: #3A1620; --warn: #F2C35B; --warn-tint: #3A2E10;
    --neutral-tint: #201F47; --focus: #A5ABF8; --shadow: none;
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text); font-family: var(--f);
  font-size: 15.5px; line-height: 1.55; min-height: 100vh; display: flex; flex-direction: column;
}
main { flex: 1; width: 100%; }
a { color: var(--brand); text-underline-offset: 2px; }
a:hover { color: var(--brand-hover); }
h1, h2, h3 { color: var(--ink); letter-spacing: -.025em; line-height: 1.2; margin: 0 0 .4em; text-wrap: balance; }
h1 { font-size: clamp(22px, 4.6vw, 30px); font-weight: 800; }
h2 { font-size: 18px; font-weight: 800; }
h3 { font-size: 15.5px; font-weight: 700; }
p { margin: 0 0 .9em; }
code, .mono { font-family: var(--mono); font-size: .88em; }
.mono { white-space: nowrap; }
.hash { font-family: var(--mono); font-size: 12px; overflow-wrap: anywhere; word-break: break-all; color: var(--muted); }
.muted { color: var(--muted); }
.small { font-size: 13.5px; }
.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; }

:focus { outline: none; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 6px; }
.skip { position: absolute; left: 12px; top: -48px; background: var(--paper); padding: 8px 12px; border-radius: 8px; z-index: 10; }
.skip:focus { top: 12px; }

/* ── Contenedores ─────────────────────────────────────────────────────────── */
.wrap { width: 100%; max-width: 1120px; margin: 0 auto; padding: 24px max(16px, env(safe-area-inset-left)) 48px; }
.wrap.narrow { max-width: 600px; }
.card { background: var(--paper); border: 1px solid var(--line); border-radius: var(--r); padding: 20px; min-width: 0; box-shadow: var(--shadow); }
.card + .card { margin-top: 16px; }
.card.flat { box-shadow: none; }
.stack > * + * { margin-top: 16px; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: minmax(0, 1fr); }
@media (min-width: 900px) { .grid-2 { grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); } }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.kicker { font-family: var(--mono); font-size: 11.5px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin: 0 0 6px; }

/* ── Marca ────────────────────────────────────────────────────────────────── */
.wm { font-weight: 800; letter-spacing: -.035em; line-height: 1; color: var(--ink); font-size: 21px; text-decoration: none; white-space: nowrap; }
.wm .b { color: var(--brand); }
.wm .prod { font-family: var(--mono); font-weight: 500; letter-spacing: 0; font-size: .5em; color: var(--brand); border: 1.5px solid currentColor; border-radius: 6px; padding: .22em .45em; margin-left: .4em; vertical-align: .3em; }
.wm.sm { font-size: 15px; }

.topbar { background: var(--paper); border-bottom: 1px solid var(--line); }
.topbar .in { max-width: 1120px; margin: 0 auto; padding: 12px 16px; display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.topbar nav { display: flex; gap: 4px; flex-wrap: wrap; }
.topbar nav a { text-decoration: none; color: var(--text); font-weight: 600; font-size: 14px; padding: 7px 11px; border-radius: 9px; }
.topbar nav a:hover { background: var(--neutral-tint); color: var(--ink); }
.topbar nav a[aria-current="page"] { background: var(--brand-tint); color: var(--brand); }
.topbar .who { margin-left: auto; display: flex; align-items: center; gap: 10px; font-size: 13.5px; color: var(--muted); min-width: 0; }
.topbar .who b { color: var(--ink); font-weight: 700; }
.who .mail { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 220px; }
@media (max-width: 640px) { .topbar .who .mail { display: none; } }

/* Barra del firmante: la empresa arriba, con su color. */
.empresa-bar { background: var(--paper); border-bottom: 1px solid var(--line); border-top: 4px solid var(--empresa); }
.empresa-bar .in { max-width: 600px; margin: 0 auto; padding: 12px 16px; display: flex; align-items: center; gap: 10px; font-weight: 700; color: var(--ink); min-width: 0; }
.empresa-bar .in span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip-empresa { flex: none; width: 32px; height: 32px; border-radius: 9px; background: var(--empresa); color: #fff; display: grid; place-items: center; font-size: 13px; font-weight: 800; letter-spacing: 0; }
.logo-empresa { height: 32px; max-width: 160px; object-fit: contain; }
/* En la pantalla del firmante la acción principal lleva el color de la empresa
   (ya oscurecido en el servidor si no daba contraste con el blanco). */
.firmante .btn:not(.sec):not(.peligro) { background: var(--empresa); color: #fff; }
.firmante .btn:not(.sec):not(.peligro):hover { background: var(--empresa-hover); color: #fff; }
.pie { text-align: center; font-size: 12px; color: var(--muted); padding: 18px 16px 28px; }
.pie a { color: inherit; }

/* ── Pastillas de estado ──────────────────────────────────────────────────── */
.pill { display: inline-flex; align-items: center; gap: 6px; font-family: var(--mono); font-size: 11.5px; font-weight: 500; letter-spacing: .02em; padding: 3px 10px; border-radius: 99px; white-space: nowrap; background: var(--neutral-tint); color: var(--muted); }
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill.marca { background: var(--brand-tint); color: var(--brand); }
.pill.sello { background: var(--seal-tint); color: var(--seal); }
.pill.alerta { background: var(--alert-tint); color: var(--alert); }
.pill.aviso { background: var(--warn-tint); color: var(--warn); }
.pill.apagado { background: var(--neutral-tint); color: var(--muted); text-decoration: line-through; }

/* ── Botones ──────────────────────────────────────────────────────────────── */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; font: inherit; font-weight: 700; font-size: 15px; line-height: 1.2; padding: 12px 18px; border-radius: 12px; border: 1.5px solid transparent; background: var(--brand); color: var(--on-brand); text-decoration: none; cursor: pointer; min-height: 46px; text-align: center; }
.btn:hover { background: var(--brand-hover); color: var(--on-brand); }
.btn.block { width: 100%; }
.btn.sec { background: transparent; color: var(--brand); border-color: var(--line); }
.btn.sec:hover { background: var(--brand-tint); }
.btn.peligro { background: transparent; color: var(--alert); border-color: var(--line); }
.btn.peligro:hover { background: var(--alert-tint); }
.btn.sm { font-size: 13.5px; padding: 7px 12px; min-height: 36px; border-radius: 10px; }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; }
.link-btn { background: none; border: 0; padding: 0; font: inherit; color: var(--brand); text-decoration: underline; cursor: pointer; }

/* ── Formularios ──────────────────────────────────────────────────────────── */
label, .label { display: block; font-weight: 600; color: var(--ink); font-size: 14px; margin-bottom: 6px; }
.hint { display: block; font-weight: 400; color: var(--muted); font-size: 13px; margin-top: 4px; }
input[type=text], input[type=email], input[type=tel], input[type=date], input[type=search], input[type=file], select, textarea {
  width: 100%; font: inherit; font-size: 16px; color: var(--text); background: var(--paper); border: 1.5px solid var(--line);
  border-radius: var(--r-sm); padding: 10px 12px; min-height: 44px; }
input[type=file] { padding: 8px; }
textarea { min-height: 96px; resize: vertical; }
input:focus-visible, select:focus-visible, textarea:focus-visible { border-color: var(--brand); outline: 3px solid color-mix(in srgb, var(--focus) 35%, transparent); outline-offset: 0; }
.field + .field { margin-top: 14px; }
.fields-2 { display: grid; gap: 14px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 640px) { .fields-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.check { display: flex; gap: 10px; align-items: flex-start; font-weight: 600; color: var(--ink); cursor: pointer; }
.check input { width: 22px; height: 22px; margin: 1px 0 0; accent-color: var(--brand); flex: none; }
.radios { display: flex; gap: 8px; flex-wrap: wrap; }
.radio { flex: 1 1 160px; display: flex; gap: 10px; align-items: flex-start; border: 1.5px solid var(--line); border-radius: var(--r-sm); padding: 10px 12px; cursor: pointer; font-weight: 600; color: var(--ink); }
.radio input { accent-color: var(--brand); margin-top: 4px; }
.radio:has(input:checked) { border-color: var(--brand); background: var(--brand-tint); }
.radio .hint { margin: 0; }
fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
legend { padding: 0; font-weight: 700; color: var(--ink); margin-bottom: 8px; }

.otp-input { font-family: var(--mono) !important; font-size: 28px !important; letter-spacing: .5em; text-align: center; padding: 10px 0 10px .5em !important; min-height: 60px !important; border-color: #C7CCFB !important; }

/* ── Avisos ───────────────────────────────────────────────────────────────── */
.aviso { border-radius: var(--r-sm); padding: 12px 14px; font-size: 14.5px; border: 1px solid transparent; margin-bottom: 14px; }
.aviso p:last-child, .aviso ul:last-child { margin-bottom: 0; }
.aviso ul { margin: 6px 0 0; padding-left: 18px; }
.aviso.ok { background: var(--brand-tint); color: var(--ink); border-color: color-mix(in srgb, var(--brand) 25%, transparent); }
.aviso.info { background: var(--neutral-tint); color: var(--text); }
.aviso.advertencia { background: var(--warn-tint); color: var(--warn); }
.aviso.error { background: var(--alert-tint); color: var(--alert); border-color: color-mix(in srgb, var(--alert) 30%, transparent); }
.aviso.sello { background: var(--seal-tint); color: var(--seal); }

/* ── Firmante ─────────────────────────────────────────────────────────────── */
.stepper { display: flex; gap: 6px; margin: 0 0 16px; padding: 0; list-style: none; }
.stepper li { flex: 1; height: 5px; border-radius: 5px; background: var(--line); }
.stepper li.on { background: var(--brand); }
.doc-ficha { border: 1px solid var(--line); border-radius: var(--r-sm); padding: 12px 14px; font-size: 13.5px; color: var(--muted); margin: 0 0 16px; }
.doc-ficha b { color: var(--ink); font-size: 15px; display: block; }
.mensaje { border-left: 3px solid var(--empresa); padding: 2px 0 2px 12px; color: var(--text); margin: 0 0 16px; white-space: pre-line; }
.visor { border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--neutral-tint); overflow: hidden; margin-bottom: 12px; }
.vista-correo { border: 1px solid var(--line); border-radius: var(--r-sm); overflow: hidden; background: #eef0f3; }
.vista-correo iframe { display: block; width: 100%; height: 640px; border: 0; }
.visor iframe { display: block; width: 100%; height: 70vh; border: 0; background: #fff; }
.paginas { max-height: 64vh; overflow-y: auto; padding: 10px; display: grid; gap: 10px; -webkit-overflow-scrolling: touch; }
.paginas img { width: 100%; height: auto; display: block; background: #fff; border-radius: 4px; box-shadow: 0 1px 3px rgba(0, 0, 0, .15); }
.visor.con-iframe .paginas { display: none; }
.rubrica { border: 1.5px dashed var(--line); border-radius: var(--r-sm); background: #fff; touch-action: none; display: block; width: 100%; height: 150px; cursor: crosshair; }
.sello-ok { display: flex; gap: 14px; align-items: center; }
.sello-ok svg { flex: none; }
.sello-ok h1 { color: var(--seal); margin: 0; }
details.rechazo { margin-top: 18px; border-top: 1px solid var(--line); padding-top: 14px; }
details.rechazo summary { cursor: pointer; color: var(--muted); font-size: 14px; font-weight: 600; }
details.rechazo[open] summary { margin-bottom: 10px; }

/* ── Tablas y listas ──────────────────────────────────────────────────────── */
.tabla { width: 100%; border-collapse: collapse; font-size: 14.5px; }
.tabla th { font-family: var(--mono); font-size: 11px; font-weight: 500; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); text-align: left; padding: 8px 12px; border-bottom: 1px solid var(--line); }
.tabla td { padding: 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
.tabla tr:last-child td { border-bottom: 0; }
.tabla a.titulo { font-weight: 700; color: var(--ink); text-decoration: none; }
.tabla a.titulo:hover { color: var(--brand); text-decoration: underline; }
/* En el celular la tabla se vuelve tarjetas apiladas. */
@media (max-width: 720px) {
  .tabla thead { display: none; }
  .tabla, .tabla tbody, .tabla tr, .tabla td { display: block; width: 100%; }
  .tabla tr { padding: 12px 0; border-bottom: 1px solid var(--line); }
  .tabla tr:last-child { border-bottom: 0; }
  .tabla tr:first-child { padding-top: 0; }
  .tabla td { border: 0; padding: 2px 0; }
  .tabla td[data-l]::before { content: attr(data-l) " · "; color: var(--muted); font-size: 12.5px; }
}
.filtros { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 14px; }
.filtros .field { flex: 1 1 220px; margin: 0; }
.filtros .field + .field { margin: 0; }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.tabs a { text-decoration: none; font-size: 13.5px; font-weight: 600; color: var(--muted); border: 1px solid var(--line); border-radius: 99px; padding: 5px 12px; background: var(--paper); }
.tabs a[aria-current="true"] { color: var(--brand); border-color: var(--brand); background: var(--brand-tint); }
.tabs a .n { font-family: var(--mono); font-size: 11.5px; margin-left: 4px; }
.vacio { text-align: center; padding: 40px 16px; color: var(--muted); }
.vacio h2 { color: var(--ink); }
.lista { list-style: none; margin: 0; padding: 0; }
.lista > li { padding: 12px 0; border-bottom: 1px solid var(--line); min-width: 0; }
.lista > li:last-child { border-bottom: 0; }
.persona { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; align-items: start; }
.persona .acciones { grid-column: 1 / -1; display: flex; gap: 8px; flex-wrap: wrap; margin-top: 6px; }
.persona .acciones details { width: 100%; }
.dl { display: grid; grid-template-columns: minmax(0, 150px) minmax(0, 1fr); gap: 8px 14px; margin: 0; font-size: 14.5px; }
.dl dt { color: var(--muted); }
.dl dd { margin: 0; color: var(--ink); min-width: 0; overflow-wrap: anywhere; }
@media (max-width: 480px) { .dl { grid-template-columns: minmax(0, 1fr); gap: 2px; } .dl dd { margin-bottom: 8px; } }
.evento { display: grid; grid-template-columns: 14px minmax(0, 1fr); gap: 10px; }
.evento::before { content: ""; width: 9px; height: 9px; border-radius: 50%; background: var(--brand); margin-top: 7px; }
.evento .hash { display: block; margin-top: 2px; }
.barra-uso { height: 6px; background: var(--line); border-radius: 6px; overflow: hidden; margin-top: 6px; }
.barra-uso span { display: block; height: 100%; background: var(--brand); }
.progreso { font-family: var(--mono); font-size: 12.5px; color: var(--muted); }

/* ── Firmantes en el formulario y ubicación ───────────────────────────────── */
.firmante-fila { border: 1px solid var(--line); border-radius: var(--r-sm); padding: 14px; position: relative; }
.firmante-fila + .firmante-fila { margin-top: 10px; }
.firmante-fila .num { font-family: var(--mono); font-size: 12px; color: var(--muted); margin-bottom: 8px; display: flex; justify-content: space-between; align-items: center; }
.ubicar-pagina { position: relative; margin: 0 0 16px; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; background: #fff; cursor: crosshair; }
.ubicar-pagina img { display: block; width: 100%; height: auto; user-select: none; -webkit-user-drag: none; }
.ubicar-pagina .n { position: absolute; top: 6px; left: 6px; font-family: var(--mono); font-size: 11px; background: rgba(30, 27, 75, .75); color: #fff; padding: 2px 7px; border-radius: 6px; }
.marca-firma { position: absolute; border: 2px solid var(--brand); background: rgba(79, 70, 229, .14); border-radius: 4px; font-size: 11px; font-weight: 700; color: #312E81; padding: 2px 4px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; pointer-events: none; }
.ubicar-lado { position: sticky; top: 12px; }
.quien { display: grid; gap: 8px; }
.quien .radio { flex: none; }

.acciones-doc { display: flex; gap: 8px; flex-wrap: wrap; }
.titulo-doc { display: flex; gap: 12px; align-items: flex-start; justify-content: space-between; flex-wrap: wrap; margin-bottom: 16px; }
.titulo-doc h1 { margin: 0; overflow-wrap: anywhere; }
.seal-badge { display: flex; gap: 12px; align-items: center; border: 1px solid var(--line); border-radius: var(--r); padding: 14px 16px; background: var(--paper); }
.seal-badge.ok { border-color: color-mix(in srgb, var(--seal) 40%, var(--line)); }
.seal-badge b { display: block; color: var(--ink); }
.mt { margin-top: 14px; }
.sello-ok { color: var(--seal); }
.uso-0 { width: 0; } .uso-1 { width: 10%; } .uso-2 { width: 20%; } .uso-3 { width: 30%; } .uso-4 { width: 40%; }
.uso-5 { width: 50%; } .uso-6 { width: 60%; } .uso-7 { width: 70%; } .uso-8 { width: 80%; background: var(--warn) !important; }
.uso-9 { width: 90%; background: var(--warn) !important; } .uso-10 { width: 100%; background: var(--alert) !important; }
.flex1 { flex: 1 1 200px; width: auto; }
.persona details summary { list-style: none; display: inline; }
.persona details summary::-webkit-details-marker { display: none; }
.topbar.narrow .in { max-width: 600px; }
@media (max-width: 640px) {
  .topbar .in { gap: 8px 12px; }
  .topbar nav { order: 3; width: 100%; }
  .topbar nav a { padding: 6px 9px; font-size: 13.5px; }
  .topbar .who { order: 2; }
}
.lista > li, .evento div { overflow-wrap: anywhere; min-width: 0; }

/* ── Plantillas ───────────────────────────────────────────────────────────── */
.ayuda code { background: var(--neutral-tint); padding: 1px 5px; border-radius: 5px; color: var(--ink); white-space: nowrap; }
.titulo-link { font-weight: 700; color: var(--ink); text-decoration: none; overflow-wrap: anywhere; }
.titulo-link:hover { color: var(--brand); text-decoration: underline; }
.campo-fila code { display: inline-block; margin-bottom: 6px; color: var(--brand); }
.fields-3 { display: grid; gap: 10px; grid-template-columns: minmax(0, 1fr); align-items: end; }
@media (min-width: 640px) { .fields-3 { grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr) auto; } }
.check-inline { min-height: 44px; align-items: center; font-weight: 500; }
.check-inline input { margin: 0; }
.dato-firmante { margin-top: 12px; }
.dato-firmante .label { margin-bottom: 4px; }
.sr-only-label { margin: 0; }
.error-campo { display: block; color: var(--alert); font-size: 13.5px; margin-top: 4px; }
.con-error input { border-color: var(--alert); }
.pasos { list-style: none; display: flex; gap: 6px; flex-wrap: wrap; padding: 0; margin: 0 0 16px; }
.pasos li { font-size: 13px; font-weight: 600; color: var(--muted); border: 1px solid var(--line); border-radius: 99px; padding: 4px 12px; background: var(--paper); }
.pasos li.on { color: var(--brand); border-color: var(--brand); background: var(--brand-tint); }
.tabla-scroll { overflow-x: auto; }
.opciones-nuevo { display: grid; gap: 10px; grid-template-columns: minmax(0, 1fr); margin-bottom: 16px; }
@media (min-width: 640px) { .opciones-nuevo { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.opcion { display: block; border: 1.5px solid var(--line); border-radius: var(--r); padding: 14px 16px; background: var(--paper); text-decoration: none; color: var(--text); }
.opcion b { display: block; color: var(--ink); }
.opcion[aria-current="true"] { border-color: var(--brand); background: var(--brand-tint); }
.opcion:hover { border-color: var(--brand); }
.plantillas-rapidas { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
