/* Minerva — Suite A (familia TERRENO) */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --bg: #0a0f17;
  --bg2: #111827;
  --paper: #F9FAFB;
  --panel: #FFFFFF;
  --ink: #111827;
  --ink2: #4B5563;
  --line: #E5E7EB;
  --blue: #1A52AD;
  --blue2: #1449A3;
  --accent: #3b82f6;
  --ok: #059669;
  --red: #DC2626;
  --ink-d: #e8eef8;
  --ink-d2: #8ba0c0;
  --sel: rgba(26,82,173,.22);
  --display: "Archivo", system-ui, sans-serif;
  --ui: Inter, system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
  --r: 8px;
  --sidebar: 220px;
}
html, body { height: 100%; }
body {
  font-family: var(--ui);
  font-size: 14px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
a { color: var(--blue); }
::selection { background: var(--sel); }

.a-cap { color: var(--accent); flex-shrink: 0; }

.brand { display: flex; align-items: center; gap: 10px; }
.brand-name { font-family: var(--display); font-weight: 800; font-size: 14px; letter-spacing: .02em; }
.brand-sub { font-size: 11px; color: var(--ink-d2); }

/* Login */
.a-login {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  background: #E9E9E5;
  color: var(--ink-d);
}
.a-login-visual {
  position: relative;
  isolation: isolate;
  padding: 48px 56px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  overflow: hidden;
  gap: 16px;
  background-color: #E9E9E5;
}
.a-login-visual::before {
  content: "";
  position: absolute; inset: 0; z-index: 0;
  background: #E9E9E5 url("/static/img/login-poster.png?v=20260907d") center 32% / cover no-repeat;
}
.a-login-visual::after {
  content: "";
  position: absolute; inset: 0; z-index: 0;
  background: linear-gradient(to top, rgba(233,233,229,.94) 0%, rgba(233,233,229,.55) 28%, transparent 58%);
}
.a-login-visual > * { position: relative; z-index: 1; }
.a-login .a-cap { color: #C83232; }
.a-lockup .brand-name { color: #30343A; font-size: 18px; }
.a-lockup .brand-sub { color: #5a5e64; }
.a-login .lede {
  margin: 0;
  max-width: 36ch;
  font-size: 16px;
  line-height: 1.5;
  color: #30343A;
}
.a-login-form {
  background: #0e1828;
  border-left: 1px solid rgba(120,160,220,.16);
  padding: 64px 48px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 22px;
}
.a-login-form h2 {
  font-family: var(--display);
  font-size: 22px;
  font-weight: 650;
  letter-spacing: -.02em;
  color: #fff;
}
.a-form { display: flex; flex-direction: column; gap: 16px; }
.a-field { display: flex; flex-direction: column; gap: 6px; }
.a-field span, .a-field label { font-size: 12px; font-weight: 600; color: var(--ink-d2); }
.a-field input {
  min-height: 44px;
  padding: 10px 12px;
  border-radius: var(--r);
  border: 1px solid rgba(120,160,220,.28);
  background: rgba(5,9,17,.6);
  color: var(--ink-d);
  caret-color: var(--accent);
}
.a-field input:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  border-color: transparent;
}
.login-check { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink-d2); }
.a-err { color: #fca5a5; font-size: 13px; min-height: 18px; }
.a-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 10px 16px;
  border-radius: var(--r); border: 1px solid transparent;
  font-weight: 650; font-size: 14px;
  background: var(--accent); color: #04101f;
  text-decoration: none;
}
.a-btn:hover { background: #60a5fa; }
.a-btn--sm { min-height: 32px; font-size: 12px; padding: 6px 10px; align-self: start; width: fit-content; }
.a-hint { font-family: var(--mono); font-size: 12px; color: var(--ink2); }

/* App shell */
.a-app {
  min-height: 100vh;
  display: grid;
  grid-template-columns: var(--sidebar) 1fr;
  background: var(--paper);
}
.a-side {
  background: var(--bg2);
  color: #F9FAFB;
  padding: 18px 14px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.a-side .brand {
  padding: 4px 6px 12px;
  border-bottom: 1px solid #1F2937;
}
.a-side .brand-name { color: #fff; }
.a-side .brand-sub { color: #9CA3AF; }
.a-nav { display: flex; flex-direction: column; gap: 4px; }
.a-nav a {
  text-align: left;
  color: #9CA3AF;
  padding: 9px 10px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
}
.a-nav a:hover { color: #fff; background: rgba(26,82,173,.18); }
.a-nav a[aria-current="page"] { background: rgba(26,82,173,.28); color: #fff; }
.a-user {
  margin-top: auto;
  padding: 10px;
  border-top: 1px solid #1F2937;
  font-size: 12px;
  color: #9CA3AF;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.a-user strong { color: #F9FAFB; font-size: 13px; }
.a-user a { color: var(--accent); text-decoration: none; margin-top: 6px; }

.a-main { display: flex; flex-direction: column; min-width: 0; min-height: 100vh; position: relative; }
.a-top {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 12px 20px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}
.a-top h1 { margin: 0; font-size: 15px; font-weight: 700; }
.a-filters { display: flex; gap: 8px; flex-wrap: wrap; }
.a-filters select {
  min-height: 32px;
  padding: 4px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  color: var(--ink);
  font-size: 12px;
}
.a-filters select:focus { outline: 2px solid var(--blue); outline-offset: 1px; }

.a-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  padding: 40px 24px 80px;
}
.a-empty h2 {
  font-family: var(--display);
  font-size: clamp(28px, 3vw, 40px);
  letter-spacing: -.03em;
  max-width: 18ch;
  text-align: center;
}
.a-composer {
  width: min(720px, 100%);
  display: flex; gap: 8px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 8px;
  box-shadow: 0 16px 40px -28px rgba(17,24,39,.5);
}
.a-composer input[type="text"] {
  flex: 1;
  border: 0;
  min-height: 48px;
  padding: 10px 12px;
  background: transparent;
  color: var(--ink);
}
.a-composer input:focus { outline: none; }
.a-composer:focus-within { outline: 2px solid var(--blue); outline-offset: 0; }
.a-sugs { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; max-width: 720px; }
.a-sugs button {
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink2);
  border-radius: 999px;
  padding: 8px 12px;
  font-size: 12px;
  font-weight: 500;
}
.a-sugs button:hover { border-color: var(--blue); color: var(--blue); }

.a-work {
  flex: 1;
  display: grid;
  grid-template-columns: 1.25fr 0.85fr;
  min-height: 0;
}
.a-answer, .a-sources { padding: 28px 32px 48px; overflow: auto; }
.a-answer { background: var(--panel); border-right: 1px solid var(--line); }
.a-answer .q { font-size: 13px; color: var(--ink2); margin: 0 0 16px; }
.resp-text { font-size: 16px; line-height: 1.65; max-width: 68ch; white-space: pre-wrap; }
.a-sources { background: var(--paper); display: flex; flex-direction: column; gap: 10px; }
.a-sources h2 { margin: 0 0 8px; font-size: 13px; font-weight: 700; }
.a-src {
  display: flex; flex-direction: column; gap: 6px;
  padding: 14px 14px 14px 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r);
}
.a-src .id { font-family: var(--mono); font-size: 12px; color: var(--blue); }
.a-src .rubro { font-size: 13px; font-weight: 650; line-height: 1.35; }
.a-src .meta { font-size: 11px; color: var(--ink2); display: flex; flex-wrap: wrap; gap: 8px; }
.a-src .extracto { font-size: 12px; color: var(--ink2); line-height: 1.5; }
.a-src a { font-size: 12px; }

.a-load {
  position: absolute; inset: 48px 0 0; display: none;
  place-items: center;
  background: rgba(249,250,251,.82);
  color: var(--ink2);
  font-size: 14px;
}
.htmx-request.a-load, .htmx-request .a-load, .htmx-indicator.htmx-request { display: grid; }
.htmx-indicator { display: none; }

.a-body { flex: 1; min-height: 0; display: flex; flex-direction: column; overflow: hidden; }
.a-search {
  display: flex; gap: 8px; align-items: center;
  padding: 12px 20px 0;
}
.a-search input[type="search"] {
  flex: 1;
  min-height: 36px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  color: var(--ink);
  font-size: 13px;
}
.a-search input:focus { outline: 2px solid var(--blue); outline-offset: 1px; }

.a-split {
  flex: 1;
  display: grid;
  grid-template-columns: 1.05fr 0.95fr;
  min-height: 0;
}
.a-list, .a-read { overflow: auto; padding: 16px 20px 48px; }
.a-list { background: var(--paper); border-right: 1px solid var(--line); }
.a-read { background: var(--panel); }
.a-doc {
  width: 100%;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px 16px;
  padding: 12px 0;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  text-align: left;
  color: inherit;
}
.a-doc[aria-current="true"] { background: #EFF6FF; margin: 0 -20px; padding-inline: 20px; width: auto; }
.a-doc .t { font-size: 13px; font-weight: 650; line-height: 1.35; grid-column: 1 / -1; }
.a-doc .m { font-size: 11px; color: var(--ink2); display: flex; flex-wrap: wrap; gap: 8px; }
.a-doc .d { font-family: var(--mono); font-size: 11px; color: var(--ink2); }
.a-read h2 { margin: 0 0 8px; font-size: 18px; letter-spacing: -.02em; max-width: 46ch; }
.a-read .m, .a-doc-page .m { font-size: 12px; color: var(--ink2); display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 18px; padding: 16px 20px 0; }
.a-read .extracto { margin: 0 0 18px; font-size: 15px; line-height: 1.65; max-width: 62ch; }
.empty-read { color: var(--ink2); font-size: 14px; margin: 48px 0 0; }

.a-hist { flex: 1; overflow: auto; padding: 8px 20px 48px; }
.a-hist table { width: 100%; border-collapse: collapse; font-size: 13px; }
.a-hist th {
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--ink2);
  padding: 10px 8px;
  border-bottom: 1px solid var(--line);
}
.a-hist td { padding: 12px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.a-hist td.num { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.a-hist tr { cursor: pointer; }
.a-hist tr:hover td { background: #EFF6FF; }
.a-hist .q { font-weight: 650; line-height: 1.35; }
.a-hist .origen { font-size: 11px; color: var(--ink2); }

.a-grafo {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 300px;
  min-height: 0;
}
.a-grafo-stage {
  position: relative;
  background: var(--panel);
  border-right: 1px solid var(--line);
  overflow: hidden;
}
.a-grafo-stage svg { width: 100%; height: 100%; display: block; min-height: 440px; }
.a-g-node { cursor: pointer; }
.a-g-node rect { fill: var(--panel); stroke: var(--line); stroke-width: 1.25; }
.a-g-node[data-kind="articulo"] rect { stroke: #6B7280; }
.a-g-node[data-kind="decreto"] rect { stroke: #059669; }
.a-g-node[aria-current="true"] rect { fill: var(--blue); stroke: var(--blue); }
.a-g-node text { font-family: var(--ui); fill: var(--ink); pointer-events: none; }
.a-g-node[aria-current="true"] text { fill: #fff; }
.a-g-label { font-size: 12px; font-weight: 700; }
.a-g-sub { font-size: 10px; fill: var(--ink2); }
.a-g-node[aria-current="true"] .a-g-sub { fill: rgba(255,255,255,.78); }
.a-g-elabel { font-size: 9px; font-weight: 700; letter-spacing: .08em; }
.a-legend {
  position: absolute; left: 16px; bottom: 16px;
  display: flex; flex-wrap: wrap; gap: 8px 14px;
  padding: 8px 10px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 11px;
  color: var(--ink2);
}
.a-legend span { display: flex; align-items: center; gap: 6px; }
.a-legend i { width: 14px; height: 2px; display: block; }
.a-g-detail { padding: 20px 20px 48px; overflow: auto; background: var(--paper); }
.a-g-detail h2 { margin: 0 0 6px; font-size: 16px; }
.a-g-detail .id { font-family: var(--mono); font-size: 12px; color: var(--blue); }
.a-g-detail p { margin: 12px 0 0; font-size: 14px; line-height: 1.55; }
.a-g-detail .m { margin-top: 10px; font-size: 12px; color: var(--ink2); display: flex; flex-wrap: wrap; gap: 8px; }
.a-g-detail .ok { color: var(--ok); font-weight: 650; }

.a-doc-page { overflow: auto; padding: 0 20px 48px; }
.doc-viewer { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 20px 24px; }
.doc-parrafo { margin: 0 0 10px; line-height: 1.7; font-size: 14px; text-align: justify; }
.doc-parrafo.highlight { background: #fef08a; padding: 2px 4px; border-radius: 3px; }
.doc-parrafo .hl-term { background: #fde047; padding: 0 2px; border-radius: 2px; font-weight: 500; }
.fuente-badge { font-size: 11px; padding: 1px 6px; border-radius: 3px; background: #DBEAFE; color: var(--blue); }

.a-visor {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(52vw, 760px);
  z-index: 40;
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border-left: 1px solid var(--line);
  box-shadow: -8px 0 24px rgba(10, 15, 23, .12);
}
.a-visor[hidden] { display: none !important; }
.a-visor-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}
.a-visor-bar strong { font-size: 13px; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.a-visor-nav { display: flex; gap: 6px; }
.a-visor-nav button {
  border: 1px solid var(--line);
  background: var(--paper);
  border-radius: 6px;
  padding: 4px 10px;
}
.a-visor-cuerpo {
  flex: 1;
  overflow: auto;
  position: relative;
  background: #525659;
}
.a-visor-cuerpo .pdfViewer { padding: 12px 0; }
#visor-msg { padding: 20px; }

@media (max-width: 900px) {
  .a-login { grid-template-columns: 1fr; }
  .a-login-visual { min-height: 34vh; }
  .a-app { grid-template-columns: 1fr; }
  .a-side { display: none; }
  .a-work, .a-split, .a-grafo { grid-template-columns: 1fr; }
  .a-visor { width: 100vw; }
}
