:root {
  --bg: #121212; --surface: #181818; --surface-raised: #202020; --line: #303030;
  --line-soft: #262626; --text: #e6e6e6; --muted: #8b8b8b; --faint: #5e5e5e;
  --focus: #d7d7d7; --selection: #2a2a2a; --warn: #d9a77a;
  --mono: "SF Mono", "Cascadia Code", "Roboto Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

/* Cualquier `display` que pongamos después pisa al atributo hidden y el elemento
   se muestra igual. Ya rompió el estado vacío del grafo, la ficha y el botón de
   Google: se corta acá, de una vez, para todos. */
[hidden] { display: none !important; }

body {
  background: var(--bg); color: var(--text);
  font: 13px/1.5 var(--mono); margin: 0; min-height: 100vh;
}

.terminal { margin: 0 auto; max-width: 1420px; padding: 18px 28px 20px; }

/* ---------------------------------------------------------- topbar */
.topbar {
  align-items: center; border-bottom: 1px solid var(--line);
  display: flex; height: 42px; justify-content: space-between; margin-bottom: 30px;
}
.wordmark {
  background: transparent; border: 0; color: #fafafa; cursor: pointer;
  font: 650 19px/1 var(--mono); letter-spacing: -.1em; padding: 0;
}
/* en todas las páginas el wordmark es un enlace a la carga; era <button> sólo
   en /grafo, y cada página se traía su propio text-decoration inline */
a.wordmark { text-decoration: none; }
.wordmark:hover { color: #fff; }
.wordmark:focus-visible { outline: 1px solid var(--focus); outline-offset: 4px; }
.wordmark span { color: var(--faint); font-size: 14px; margin-left: 1px; }
.path { color: var(--muted); font-size: 11px; }
.path span { color: var(--faint); }
.local-status { color: var(--muted); font-size: 10px; text-transform: uppercase; }
.local-status { align-items: center; display: flex; gap: 10px; }
/* Navegación entre las dos páginas. Va en minúscula, igual que los enlaces del
   pie de la página de carga: el estado del motor grita en mayúsculas, la
   navegación no tiene por qué. La línea la separa de ese estado. */
.navegacion {
  align-items: center; border-left: 1px solid var(--line); display: flex;
  gap: 12px; margin-left: 14px; padding-left: 14px; text-transform: none;
}
.navegacion .text-button { font-size: 10px; }

.local-status i {
  background: #a5a5a5; border-radius: 50%; display: inline-block;
  height: 5px; margin: 0 6px 1px 0; width: 5px;
}

/* ---------------------------------------------------------- tipografía */
h1, h2, p { margin-top: 0; }
h2 { font-size: 14px; font-weight: 500; letter-spacing: -.02em; margin: 0; }
.eyebrow { color: var(--faint); font-size: 10px; letter-spacing: .05em; margin-bottom: 5px; }

/* ---------------------------------------------------------- paneles */
.panel { border: 1px solid var(--line); }
.section-heading, .result-heading { align-items: start; display: flex; justify-content: space-between; padding: 16px 18px; }
.section-heading { border-bottom: 1px solid var(--line); }
.text-button {
  background: transparent; border: 0; color: var(--muted);
  cursor: pointer; font: 11px var(--mono); padding: 0;
}
.text-button:hover { color: var(--text); }
a.text-button { text-decoration: none; }
.text-button.activo { color: var(--text); }

form { padding: 18px; }

textarea, input, select {
  background: var(--surface); border: 1px solid var(--line); border-radius: 0;
  color: var(--text); font: 12px/1.55 var(--mono); outline: none; padding: 9px; width: 100%;
}
input { height: 30px; padding: 0 9px; }
textarea { resize: vertical; min-height: 62px; }
textarea::placeholder, input::placeholder { color: var(--faint); }
textarea:focus, input:focus, select:focus { border-color: var(--focus); }

.options {
  align-items: end; border-top: 1px solid var(--line-soft); display: flex;
  flex-wrap: wrap; gap: 18px; justify-content: space-between;
  margin-top: 16px; padding-top: 14px;
}
fieldset { border: 0; display: flex; gap: 12px; margin: 0; padding: 0; }
fieldset label { color: var(--muted); display: block; font-size: 10px; }
fieldset input { accent-color: #bdbdbd; height: auto; margin: 0 4px 0 0; vertical-align: -1px; width: auto; }
legend { color: var(--faint); font-size: 10px; margin-bottom: 5px; }

.search-button {
  background: var(--text); border: 1px solid var(--text); border-radius: 0; color: #111;
  cursor: pointer; font: 600 11px var(--mono); height: 30px; min-width: 110px; padding: 0 12px;
}
.search-button:hover { background: #fff; border-color: #fff; }
.search-button:disabled { background: transparent; border-color: var(--line); color: var(--faint); cursor: default; }

.hint { color: var(--faint); font-size: 10px; margin: 14px 0 0; }
kbd { border: 1px solid var(--line); color: var(--muted); font: inherit; padding: 0 3px; }

.message {
  background: #211b17; border: 1px solid #4d3c30; color: var(--warn);
  font-size: 10px; margin-top: 12px; padding: 9px 12px;
}

.respuesta {
  border-top: 1px solid var(--line-soft); color: #cbcbcb;
  font-size: 12px; margin-top: 14px; padding-top: 14px; white-space: pre-wrap;
}
.respuesta strong { color: #fafafa; font-weight: 600; }

/* ---------------------------------------------------------- salida */
.results-section { margin-top: 28px; }
.result-heading { border: 1px solid var(--line); border-bottom: 0; padding: 14px 18px; }
.result-actions { align-items: end; display: flex; flex-direction: column; gap: 8px; }
.controles { align-items: center; display: flex; gap: 14px; }
.controles input { width: 190px; }
#estado-registro { color: var(--muted); font-size: 10px; margin: 0; text-align: right; }

.leyenda { display: flex; flex-wrap: wrap; gap: 12px; justify-content: flex-end; }
.leyenda button {
  align-items: center; background: transparent; border: 0; color: var(--muted);
  cursor: pointer; display: flex; font: 10px var(--mono); gap: 5px; padding: 0;
}
.leyenda button:hover { color: var(--text); }
.leyenda button.off { color: #3c3c3c; }
.leyenda .muestra { border-top: 1px solid currentColor; display: inline-block; width: 16px; }
.leyenda .muestra.dashed { border-top-style: dashed; }
.leyenda .muestra.dotted { border-top-style: dotted; }

.salida { border: 1px solid var(--line); display: flex; min-height: 520px; }
.lienzo-wrap { flex: 1; min-width: 0; position: relative; }
#lienzo { cursor: grab; display: block; height: 100%; inset: 0; position: absolute; width: 100%; }
.ficha {
  border-left: 1px solid var(--line); flex: none; max-height: 68vh;
  overflow: auto; padding: 14px 16px; width: 340px;
}

.empty { color: var(--muted); font-size: 11px; padding: 30px; text-align: center; }
#vacio { left: 0; position: absolute; right: 0; top: 40%; }

/* ---------------------------------------------------------- sugerencias */
.sugerencias {
  background: var(--surface); border: 1px solid var(--line);
  left: 12px; max-height: 320px; overflow: auto; position: absolute; top: 12px; width: 260px; z-index: 5;
}
.sugerencias button {
  align-items: center; background: transparent; border: 0; border-bottom: 1px solid var(--line-soft);
  color: #cbcbcb; cursor: pointer; display: flex; font: 11px var(--mono);
  gap: 8px; padding: 7px 10px; text-align: left; width: 100%;
}
.sugerencias button:last-child { border-bottom: 0; }
.sugerencias button:hover, .sugerencias button.activa { background: var(--selection); color: var(--text); }
.sugerencias .marca { color: var(--faint); width: 10px; }
.sugerencias .grado { color: var(--faint); margin-left: auto; }

/* ---------------------------------------------------------- ficha */
.ficha h3 {
  align-items: baseline; display: flex; font-size: 13px; font-weight: 600;
  gap: 7px; margin: 0 0 3px; overflow-wrap: anywhere;
}
.ficha h3 .marca { color: var(--muted); font-size: 11px; }
.ficha .meta { color: var(--faint); font-size: 10px; margin-bottom: 14px; }
.ficha h4 {
  border-bottom: 1px solid var(--line-soft); color: var(--faint); font-size: 9px;
  font-weight: 500; letter-spacing: .045em; margin: 16px 0 0; padding-bottom: 5px; text-transform: uppercase;
}
.ficha select { font-size: 10px; height: 22px; padding: 0 4px; width: auto; }
.ficha table { border-collapse: collapse; font-size: 11px; table-layout: fixed; width: 100%; }
.ficha td { border-bottom: 1px solid var(--line-soft); padding: 6px 0; vertical-align: top; }
.ficha tr:last-child td { border-bottom: 0; }
.ficha .pred { color: var(--muted); overflow-wrap: anywhere; padding-right: 8px; width: 42%; }
.ficha .val { color: #cbcbcb; overflow-wrap: anywhere; }
.ficha .cuando { color: var(--faint); padding-left: 8px; text-align: right; white-space: nowrap; width: 84px; }
.ficha .quitar {
  background: transparent; border: 0; color: transparent; cursor: pointer;
  font: 10px var(--mono); padding: 0 0 0 6px;
}
.ficha tr:hover .quitar { color: var(--faint); }
.ficha .quitar:hover { color: var(--warn); }
.ficha .fuente { border-left: 1px solid var(--line); color: var(--faint); font-size: 10px; margin: 8px 0; padding-left: 9px; }
.enlace { background: transparent; border: 0; color: #cbcbcb; cursor: pointer; font: inherit; padding: 0; text-align: left; }
.enlace:hover { color: #fff; text-decoration: underline; }
.acciones-ficha { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 12px; }

/* ---------------------------------------------------------- registro */
.table-wrap { border: 1px solid var(--line); max-height: 46vh; overflow: auto; }
table { border-collapse: collapse; font-size: 11px; width: 100%; }
.table-wrap table { table-layout: fixed; }
.registro th:nth-child(1), .registro td:nth-child(1) { width: 15%; }
.registro th:nth-child(2), .registro td:nth-child(2) { width: 13%; }
.registro th:nth-child(3), .registro td:nth-child(3) { width: 16%; }
.registro th:nth-child(4), .registro td:nth-child(4) { width: 84px; }
.registro th:nth-child(5), .registro td:nth-child(5) { width: 12%; }
.registro th:nth-child(6), .registro td:nth-child(6) { width: 130px; }
.registro th:nth-child(8), .registro td:nth-child(8) { width: 124px; }
.autor { color: var(--muted); overflow-wrap: anywhere; }
.quien-lo-dijo { color: var(--faint); display: block; font-style: normal; margin-top: 3px; }
.autor.sin { color: var(--faint); font-style: italic; }
.controles select {
  background: var(--surface); border: 1px solid var(--line); border-radius: 0;
  color: var(--text); font: 11px var(--mono); height: 24px; padding: 0 4px;
}

.cuentas th:nth-child(2), .cuentas td:nth-child(2) { width: 140px; }
.cuentas th:nth-child(3), .cuentas td:nth-child(3),
.cuentas th:nth-child(4), .cuentas td:nth-child(4) { width: 150px; }
.cuentas th:nth-child(5), .cuentas td:nth-child(5) { width: 90px; }
.cuentas select { background: var(--surface); border: 1px solid var(--line); border-radius: 0; color: var(--text); font: 11px var(--mono); height: 24px; padding: 0 4px; }
.cuentas select:disabled { background: transparent; border-color: transparent; color: var(--muted); }

.vigencias th:nth-child(1), .vigencias td:nth-child(1) { width: 96px; }
.vigencias th:nth-child(2), .vigencias td:nth-child(2) { width: 15%; }
.vigencias th:nth-child(3), .vigencias td:nth-child(3) { width: 13%; }
.vigencias th:nth-child(4), .vigencias td:nth-child(4) { width: 15%; }
.vigencias th:nth-child(5), .vigencias td:nth-child(5),
.vigencias th:nth-child(6), .vigencias td:nth-child(6) { width: 82px; }
.vigencias th:nth-child(7), .vigencias td:nth-child(7) { width: 124px; }

/* el color queda reservado para advertencias: lo vencido y lo que está por vencer */
.estado { font-size: 9px; letter-spacing: .04em; text-transform: uppercase; }
.estado.vencido, .estado.por-vencer { color: var(--warn); }
.estado.vigente { color: var(--muted); }
.estado.abierto { color: var(--faint); }
tr.alerta td { background: #1b1613; }
.monto { color: #e6e6e6; white-space: nowrap; }
#estado-vigencias { color: var(--muted); font-size: 10px; margin: 0; text-align: right; }
#estado-vigencias .aviso { color: var(--warn); }
th {
  background: var(--surface); color: var(--muted); font-size: 9px; font-weight: 500;
  letter-spacing: .045em; position: sticky; text-align: left; text-transform: uppercase; top: 0; white-space: nowrap;
}
th, td { border-bottom: 1px solid var(--line-soft); padding: 8px 12px; vertical-align: top; }
td { color: #cbcbcb; overflow-wrap: anywhere; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--selection); }
tr.pendiente td { color: var(--faint); font-style: italic; }
tr.fallo td { color: var(--warn); }
tr.origen td { color: var(--muted); }
tr.origen { border-top: 1px solid var(--line); }
td.num { color: var(--faint); white-space: nowrap; }
td.acc { text-align: right; }
td.acc .text-button { display: block; margin-left: auto; }
.marca-tipo { color: var(--faint); padding-right: 5px; }

/* ---------------------------------------------------------- pie */
footer {
  border-top: 1px solid var(--line-soft); color: var(--faint); display: flex; flex-wrap: wrap;
  font-size: 10px; gap: 7px; margin: 24px auto 0; max-width: 1420px; padding: 11px 28px 22px;
}
footer span { border: 1px solid var(--line); color: var(--muted); padding: 0 4px; }

::-webkit-scrollbar { height: 8px; width: 8px; }
::-webkit-scrollbar-thumb { background: #333; }
::-webkit-scrollbar-track { background: transparent; }

@media (max-width: 980px) {
  .terminal { padding: 12px 12px 20px; }
  .path { display: none; }
  .salida { flex-direction: column; }
  .ficha { border-left: 0; border-top: 1px solid var(--line); max-height: none; width: auto; }
  .lienzo-wrap { min-height: 420px; }
  .result-heading { align-items: start; flex-direction: column; gap: 12px; }
  .result-actions { align-items: start; width: 100%; }
  .leyenda { justify-content: flex-start; }
  footer { padding: 11px 12px 22px; }
}

/* --- huecos: lo que el software todavía no sabe de una entidad --- */
.huecos { list-style: none; margin: 8px 0 0; padding: 0; }
.huecos li { align-items: baseline; display: flex; gap: 8px; padding: 2px 0; }
.hueco {
  background: transparent; border: 0; border-bottom: 1px dotted var(--line);
  color: var(--muted); cursor: pointer; font: 11px var(--mono);
  padding: 1px 0; text-align: left;
}
.hueco::before { color: var(--faint); content: '? '; }
.hueco:hover { border-bottom-color: var(--focus); color: var(--text); }
.descartar {
  background: transparent; border: 0; color: transparent;
  cursor: pointer; font: 10px var(--mono); padding: 0 2px;
}
.huecos li:hover .descartar { color: var(--faint); }
.descartar:hover { color: var(--warn); }
