/* NexaKeys — componentes de consulta compartidos por ambos paneles */

/* Buscador */
.doc-tabs { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 1px; border: 1px solid var(--line); border-radius: var(--r-lg) var(--r-lg) 0 0; background: var(--line); overflow: hidden; }
.doc-tabs button { min-width: 0; padding: 12px 10px; font-weight: 500; color: var(--ink-2); background: var(--surface-2); display: flex; flex-direction: column; align-items: flex-start; gap: 2px; text-align: left; }
.doc-tabs button small { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: var(--mono); font-size: 10.5px; color: var(--ink-3); font-weight: 400; letter-spacing: .04em; }
.doc-modes { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-bottom: 16px; }
.doc-modes .eyebrow { margin-right: 4px; }
.doc-tabs button.on { background: var(--surface); color: var(--ink); box-shadow: inset 0 -2px 0 var(--ink); }
.query-box { border: 1px solid var(--line); border-top: 0; border-radius: 0 0 var(--r-lg) var(--r-lg); background: var(--surface); padding: 18px; }
.query-input { display: flex; align-items: center; gap: 12px; border: 1px solid var(--line-2); border-radius: var(--r); padding: 0 14px; background: var(--bg); }
.query-input:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.query-input input { flex: 1; min-width: 0; height: 56px; border: 0; outline: none; background: transparent; font-family: var(--mono); font-size: 22px; letter-spacing: .06em; }
.query-input input::placeholder { color: var(--ink-3); letter-spacing: .02em; }
.query-input .count { font-family: var(--mono); font-size: 12px; color: var(--ink-3); white-space: nowrap; }
.query-input .count.ok { color: var(--ok); }
.query-hint { font-size: 12.5px; color: var(--ink-3); margin-top: 8px; min-height: 18px; }
.query-hint.err { color: var(--crit); }
.query-input select { flex: 1; min-width: 0; height: 56px; border: 0; outline: none; background: transparent; font-size: 16px; }
/* Formularios de varios campos: en columnas y con letra más chica */
.query-fields.multi { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 0 12px; }
.query-fields.multi .query-input input, .query-fields.multi .query-input select { height: 46px; font-size: 16px; letter-spacing: .02em; }
.query-fields .wide { grid-column: 1 / -1; }
/* Foto (reconocimiento facial) */
.query-file { position: relative; display: flex; align-items: center; gap: 14px; margin-top: 8px; padding: 12px 14px; border: 1px dashed var(--line-2); border-radius: var(--r); background: var(--bg); cursor: pointer; }
.query-file:hover, .query-file:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.query-file input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.query-file .thumb { width: 64px; height: 64px; flex: none; display: grid; place-items: center; border-radius: var(--r); background: var(--surface-2); color: var(--ink-3); overflow: hidden; }
.query-file .thumb img { width: 100%; height: 100%; object-fit: cover; }

.svc-head { display: flex; align-items: center; justify-content: space-between; margin: 20px 0 10px; gap: 12px; flex-wrap: wrap; }
.svc-head h2 { font-size: 13px; font-weight: 600; }
.svc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 8px; }
.svc {
  display: grid; grid-template-columns: 18px 1fr auto; gap: 10px; align-items: start;
  padding: 11px 12px; border-radius: var(--r); text-align: left;
  border: 1px solid var(--line); background: var(--surface);
}
.svc:hover { border-color: var(--line-2); }
.svc .box { width: 16px; height: 16px; margin-top: 2px; border-radius: 4px; border: 1.5px solid var(--line-2); display: grid; place-items: center; }
.svc .box svg { width: 12px; height: 12px; stroke-width: 3; opacity: 0; color: var(--accent-ink); }
.svc .name { font-weight: 500; font-size: 13.5px; }
.svc .desc { font-size: 12px; color: var(--ink-3); margin-top: 1px; }
.svc .cost { font-family: var(--mono); font-size: 12px; color: var(--ink-2); white-space: nowrap; padding-top: 2px; }
.svc.on { border-color: var(--ink); background: var(--surface-2); }
.svc.on .box { background: var(--accent-fill); border-color: var(--accent-fill); }
.svc.on .box svg { opacity: 1; }
/* Servicios que piden otro dato */
.svc.otro { opacity: .62; border-style: dashed; }
.svc.otro:hover, .svc.otro:focus-visible { opacity: 1; }
.svc.otro .box { visibility: hidden; }
.svc-sep, .svc-otros { grid-column: 1 / -1; }
.svc-sep { margin-top: 6px; font-size: 12px; color: var(--ink-3); }
.svc-otros summary { cursor: pointer; padding: 6px 0; font-size: 12.5px; color: var(--ink-2); }
.svc-otros > .svc-grid { margin-top: 8px; }

/* Encargo (solo admin) */
.encargo { margin-top: 16px; padding: 12px 14px; border: 1px dashed var(--line-2); border-radius: var(--r); background: var(--surface-2); }
.encargo.on { border-style: solid; border-color: var(--accent); }
.encargo-toggle { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-size: 13px; cursor: pointer; }
.encargo-fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 0 12px; margin-top: 12px; }
.encargo-fields .field { margin-bottom: 0; }

.run-bar {
  position: sticky; bottom: 16px; z-index: 10; margin-top: 16px;
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  padding: 12px 12px 12px 18px; border-radius: var(--r-lg);
  background: var(--ink); color: var(--bg); box-shadow: var(--shadow);
}
.run-bar .sum { flex: 1; min-width: 160px; font-size: 13px; }
.run-bar .sum b { font-family: var(--mono); font-size: 16px; font-weight: 600; }
.run-bar .sum .warn { color: var(--high); }
.run-bar .btn-primary { height: 40px; padding: 0 18px; }
.run-bar .btn-primary:disabled { opacity: .45; }

/* Resultados */
.results { margin-top: 24px; display: flex; flex-direction: column; gap: 16px; }
.results-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.results-head h2 { font-size: 15px; font-weight: 600; }
.result { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); overflow: hidden; }
.result-top { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.result-top h3 { font-size: 14px; font-weight: 600; }
.result-top .grow { flex: 1; }
.result-top .meta { font-size: 12px; color: var(--ink-3); font-family: var(--mono); }
.result-body { padding: 16px; }
.result.pending .result-body { color: var(--ink-3); display: flex; align-items: center; gap: 10px; }
.result.failed .result-body, .result.is-empty .result-body { color: var(--ink-2); font-size: 13px; }
.spinner { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--line-2); border-top-color: var(--ink); animation: spin .7s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }

.fields { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 0; border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
.fields > div { padding: 10px 12px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); min-width: 0; margin: 0 -1px -1px 0; }
.fields dt { font-family: var(--mono); font-size: 10.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-3); }
.fields dd { margin-top: 3px; font-size: 13.5px; overflow-wrap: anywhere; }
.fields dd.mono { font-family: var(--mono); }
.subsection { margin-top: 16px; }
.subsection > h4 { font-size: 12.5px; font-weight: 600; margin-bottom: 8px; color: var(--ink-2); display: flex; align-items: center; gap: 8px; }
.subsection > h4 .tag { font-weight: 400; }
.result table { font-size: 13px; }
.result th, .result td { padding: 8px 12px; }
.result .table-wrap { border: 1px solid var(--line); border-radius: var(--r); }
.photo { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.photo figure { margin: 0; }
.photo img { display: block; height: 180px; width: auto; max-width: 240px; object-fit: contain; border-radius: var(--r); border: 1px solid var(--line); background: #fff; }
.photo figcaption { display: flex; align-items: center; justify-content: space-between; gap: 6px; font-size: 12px; color: var(--ink-3); margin-top: 4px; }
/* Resultado de solo imágenes */
.photo.grande { gap: 16px; }
.photo.grande figure { flex: 1 1 340px; max-width: 560px; }
.photo.grande img { width: 100%; height: auto; max-width: none; max-height: 460px; }
.photo.grande figcaption { font-size: 13px; color: var(--ink-2); font-weight: 500; margin-top: 6px; }
.img-dl { display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: var(--r); border: 1px solid var(--line); background: var(--surface); color: var(--ink-2); cursor: pointer; flex: none; }
.img-dl:hover { border-color: var(--line-2); color: var(--ink); }
.img-dl .i { width: 14px; height: 14px; }
@media print { .img-dl { display: none; } }
img[data-zoom] { cursor: zoom-in; }

/* Ficha de persona (RENIEC) */
.persona { display: flex; gap: 20px; align-items: flex-start; padding-bottom: 18px; margin-bottom: 18px; border-bottom: 1px solid var(--line); }
.persona-foto { margin: 0; flex: none; width: 150px; aspect-ratio: 3 / 4; border-radius: var(--r); border: 1px solid var(--line); background: var(--surface-2); overflow: hidden; display: grid; place-items: center; color: var(--ink-3); }
.persona-foto img { width: 100%; height: 100%; object-fit: cover; display: block; }
.persona-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 8px; }
.persona-dni { display: flex; align-items: baseline; gap: 8px; }
.persona-dni b { font-size: 22px; font-weight: 600; letter-spacing: .04em; }
.persona-dni .dv { color: var(--ink-3); font-size: 16px; margin-left: -6px; }
.persona-nombre { font-size: 20px; font-weight: 400; line-height: 1.25; overflow-wrap: anywhere; }
.persona-nombre span { font-weight: 600; }
.persona .chips { display: flex; gap: 6px; flex-wrap: wrap; }
.persona-bio { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 6px; }
.persona-bio figure { margin: 0; }
.persona-bio img { display: block; height: 84px; width: auto; max-width: 180px; object-fit: contain; padding: 4px; border-radius: var(--r); border: 1px solid var(--line); background: #fff; }
.persona-bio figcaption { font-size: 11.5px; color: var(--ink-3); margin-top: 3px; }
.persona-grupos { display: grid; grid-template-columns: repeat(auto-fit, minmax(max(340px, 40%), 1fr)); gap: 16px 20px; }
.grupo > h4 { font-size: 12.5px; font-weight: 600; color: var(--ink-2); margin-bottom: 8px; }
.grupo .fields { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grupo .fields .ancho { grid-column: 1 / -1; }
.grupo .fields dd .badge { margin-left: 6px; vertical-align: 1px; }

/* Imagen ampliada */
.zoom-box { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 24px; background: rgba(17,17,15,.82); cursor: zoom-out; }
.zoom-box figure { margin: 0; text-align: center; }
.zoom-box img { max-width: min(92vw, 900px); max-height: 82vh; border-radius: var(--r); background: #fff; }
.zoom-box figcaption { margin-top: 8px; color: #edece6; font-size: 13px; }

/* Listas de registros */
.igual { margin-bottom: 12px; }
.igual-t { font-size: 12px; color: var(--ink-3); margin-bottom: 6px; }
.table-wrap.recortada tbody tr:nth-child(n+11) { display: none; }
.ver-todos { display: block; width: 100%; padding: 9px; border: 0; border-top: 1px solid var(--line); background: var(--surface-2); color: var(--ink-2); font-size: 12.5px; font-weight: 500; cursor: pointer; }
.ver-todos:hover { color: var(--ink); }
.table-wrap:not(.recortada) .ver-todos { display: none; }
.ceros { margin-top: 8px; }
.ceros summary { cursor: pointer; font-size: 12.5px; color: var(--ink-2); padding: 4px 0; }
.ceros .fields { margin-top: 6px; }
@media print { .table-wrap.recortada tbody tr { display: table-row; } .ver-todos { display: none; } }

/* Visor de PDF */
.pdf-view { border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; margin-bottom: 12px; background: var(--surface-2); }
.pdf-view + .pdf-view { margin-top: 12px; }
.pdf-bar { display: flex; align-items: center; gap: 8px; padding: 8px 8px 8px 12px; border-bottom: 1px solid var(--line); background: var(--surface); flex-wrap: wrap; }
.pdf-bar > .i { color: var(--ink-3); flex: none; }
.pdf-name { flex: 1; min-width: 0; font-family: var(--mono); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pdf-view:not(:has(.pdf-frame)) .pdf-bar { border-bottom: 0; }
.pdf-frame { display: block; width: 100%; height: 640px; min-height: 320px; max-height: 90vh; border: 0; resize: vertical; background: #fff; }

.notice { padding: 10px 12px; border-radius: var(--r); font-size: 13px; display: flex; gap: 8px; align-items: flex-start; }
.notice.info { background: var(--info-soft); color: var(--info); }
.notice.warn { background: var(--warn-soft); color: var(--warn); }
.notice a { color: inherit; font-weight: 600; }

/* Pantallas medianas: pestañas en una fila, sin texto de ayuda */
@media (max-width: 1100px) { .doc-tabs button small { display: none; } }
@media (max-width: 640px) {
  .doc-tabs { grid-auto-flow: row; grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .doc-tabs button { padding: 10px 6px; font-size: 13px; }
  .query-input input { font-size: 18px; height: 50px; }
  .pdf-frame { height: 70vh; }
  .persona { flex-direction: column; align-items: center; text-align: center; }
  .persona-main { align-items: center; }
  .persona .chips, .persona-bio { justify-content: center; }
  .persona-grupos { grid-template-columns: 1fr; }
  .fields { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .run-bar { bottom: 8px; }
}

/* Al imprimir no va el visor de PDF */
@media print { .pdf-frame { display: none; } .pdf-bar .btn { display: none; } }
