:root {
  color-scheme: light;
  --ink: #1c1914;
  --muted: #5c564c;
  --paper: #f4f0e6;
  --panel: #fffdf8;
  --line: #ddd4c4;
  --seal: #7d1f1f;
  --seal-soft: #f6e7e4;
  --pine: #1e4636;
  --pine-soft: #e5f0ea;
  --amber: #8a5a12;
  --amber-soft: #f8efd8;
  --navy: #1d3550;
  --navy-soft: #e7eef5;
  --shadow: 0 1px 0 rgba(28, 25, 20, 0.04);
  color: var(--ink);
  background: var(--paper);
  font-family: "Libre Franklin", "Avenir Next", "Segoe UI", sans-serif;
  font-size: 17px;
  line-height: 1.5;
}

/* Puesto de trabajo: superficies y acciones semánticas sobre el stack existente. */
.workspace {
  --action: #2849b8;
  --action-text: #ffffff;
  --focus: #315dd8;
  --complete-bg: #e5f0ea;
  --complete-ink: #1e4636;
  --subtle: #eee9df;
  font-size: 16px;
}
.workspace h1, .workspace h2, .workspace h3 { font-family: inherit; letter-spacing: -.025em; }
.workspace h1 { font-size: clamp(1.7rem, 4vw, 2.15rem); overflow-wrap: anywhere; }
.workspace h2 { font-size: 1.15rem; }
.workspace main { max-width: 1220px; padding-top: 2.3rem; }
.workspace .site-header { background: var(--panel); color: var(--ink); border-bottom: 1px solid var(--line); }
.workspace .brand { font-size: 1.15rem; font-weight: 700; margin-bottom: .3rem; }
.workspace .brand-kicker { color: var(--muted); letter-spacing: .12em; }
.workspace nav { margin-top: 1rem; align-items: start; }
.workspace nav a { color: var(--ink); border-radius: 6px; }
.workspace nav a[aria-current] { background: var(--subtle); font-weight: 700; }
.workspace button, .workspace .button { background: var(--action); color: var(--action-text); cursor: pointer; min-height: 44px; font-weight: 600; }
.workspace button:hover, .workspace .button:hover { filter: brightness(.94); }
.workspace button:disabled { cursor: not-allowed; opacity: .55; }
.workspace a { color: var(--action); text-underline-offset: .17em; }
.workspace a.button { color: var(--action-text); white-space: normal; }
.workspace .site-header a { color: var(--ink); }
.workspace input, .workspace select, .workspace textarea { min-width: 0; width: 100%; color: var(--ink); background: var(--panel); border: 1px solid var(--muted); border-radius: 7px; padding: .7rem; font: inherit; }
.workspace textarea { resize: vertical; min-height: 7rem; }
.workspace textarea[readonly] { background: var(--subtle); }
.workspace :focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }
.workspace label { color: var(--ink); font-size: .9rem; gap: .5rem; }
.workspace fieldset { border: 1px solid var(--line); border-radius: 8px; padding: 1rem; min-width: 0; }
.workspace legend { font-weight: 600; font-size: .9rem; padding: 0 .4rem; }
.workspace hr { border: 0; border-top: 1px solid var(--line); width: 100%; margin: 1.3rem 0; }
.skip-link { position: absolute; left: 1rem; top: -5rem; padding: .8rem; z-index: 10; background: var(--panel); }
.skip-link:focus { top: 1rem; }
.work-header-row, .work-row, .work-heading, .work-account, .work-actions { display: flex; gap: 1rem; justify-content: space-between; align-items: center; flex-wrap: wrap; }
.work-heading { align-items: start; margin-bottom: 1.8rem; }
.work-heading > div { max-width: 78ch; min-width: 0; }
.work-heading p:last-child { margin-bottom: 0; }
.work-account { font-size: .85rem; justify-content: end; }
.work-account form { margin: 0; }
.workspace .work-signout, .workspace .work-secondary { background: var(--subtle); color: var(--ink); }
.work-eyebrow { font-size: .7rem; font-weight: 700; letter-spacing: .12em; color: var(--muted); margin: 0 0 .7rem; }
.work-small { font-size: .85rem; line-height: 1.55; }
.work-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.2rem; }
.work-surface, .work-case, .work-empty { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 1.5rem; min-width: 0; overflow-wrap: anywhere; }
.work-case { display: flex; flex-direction: column; gap: .5rem; }
.work-case h2 { margin-top: .6rem; }
.work-case p { margin: .3rem 0; }
.work-badge { display: inline-block; padding: .3rem .6rem; border-radius: 5px; background: var(--subtle); color: var(--ink); font-size: .75rem; font-weight: 700; }
.work-next { padding: 1.2rem; border-left: 3px solid var(--complete-ink); background: var(--complete-bg); border-radius: 0 8px 8px 0; color: var(--complete-ink); margin: 1rem 0; }
.work-next p { margin: .25rem 0 0; }
.work-next .work-eyebrow { color: inherit; }
.work-empty { grid-column: 1 / -1; padding: 3rem 2rem; }
.work-empty p { max-width: 65ch; }
.work-explainer { border-top: 1px solid var(--line); padding-top: 1.5rem; margin-top: 2.5rem; }
.work-explainer p { line-height: 1.9; }
.work-form { display: flex; flex-direction: column; gap: 1.2rem; }
.work-form.work-surface { max-width: 850px; }
.work-form button { align-self: start; }
.work-form p { margin: 0; }
.work-actions { justify-content: start; }
.work-note { padding: 1rem; background: var(--subtle); border-radius: 8px; }
.work-note p { margin: .4rem 0 0; font-size: .9rem; }
.work-notice { padding: 1rem 1.2rem; background: var(--complete-bg); color: var(--complete-ink); border-radius: 8px; margin: 1rem 0; }
.work-error { background: var(--seal-soft); color: var(--seal); border-left: 3px solid var(--seal); }
.work-columns { display: grid; grid-template-columns: minmax(0, 1fr) 310px; gap: 1.5rem; align-items: start; }
.work-sidebar { display: flex; flex-direction: column; gap: 1rem; min-width: 0; }
.work-sidebar h2 { font-size: 1rem; }
.work-sidebar a, .work-pre { overflow-wrap: anywhere; }
.work-steps { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); padding: 0; list-style: none; gap: .5rem; margin: 1.5rem 0 2rem; }
.work-steps li { padding: .7rem; border-bottom: 2px solid var(--line); font-size: .8rem; color: var(--muted); }
.work-steps li[aria-current] { color: var(--action); border-bottom-color: var(--action); }
.work-steps span { display: block; font-size: .7rem; margin-top: .4rem; }
.work-plan-field { padding: 1.2rem 0; border-top: 1px solid var(--line); }
.work-plan-field p { margin: .5rem 0 .8rem; }
.work-crumb { font-size: .8rem; margin: 0 0 1.4rem; color: var(--muted); }
.work-history { margin-top: 1.5rem; }
.work-history ol { list-style: none; padding: 0; }
.work-history li { border-bottom: 1px solid var(--line); padding: 1rem 0; }
.work-history li:last-child { border-bottom: 0; }
.work-history p { margin: .4rem 0 0; }
.work-pre { white-space: pre-wrap; }
.work-stack { display: flex; flex-direction: column; gap: 1rem; min-width: 0; }
.work-surface h3 { overflow-wrap: anywhere; }
.work-upload { padding: 0; border: 0; }
.work-upload > summary { font-weight: 700; color: var(--action); padding: .7rem 0; }
.work-upload > form { margin-top: 1rem; }
.work-doc-versions { list-style: none; padding: 0; }
.work-doc-versions > li { border-top: 1px solid var(--line); margin-top: 1rem; padding-top: 1rem; }
.work-doc-versions p { overflow-wrap: anywhere; }
.work-digest { overflow-wrap: anywhere; font-family: monospace; font-size: .8rem; }
.work-cut { margin-top: 1.5rem; }
.work-table-wrap { max-width: 100%; overflow-x: auto; }
.work-table-wrap table { table-layout: fixed; }
.work-table-wrap td { overflow-wrap: anywhere; }
.work-table-wrap caption { text-align: left; font-size: .8rem; padding: .8rem 0; color: var(--muted); }
.work-warning { color: var(--seal); font-size: .8rem; }
.login-panel { max-width: 450px; margin: 2rem auto; }
.login-panel > .muted { margin-bottom: 1.8rem; }
.work-tools { position: relative; margin: .3rem .5rem; }
.work-tools summary { font-size: .85rem; cursor: pointer; padding: .4rem; }
.work-tools > div { display: flex; flex-wrap: wrap; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: .6rem; max-width: 650px; }
.workspace .site { color: var(--muted); font-size: .8rem; }
@media (max-width: 850px) {
  .work-columns { grid-template-columns: minmax(0, 1fr); }
  .work-steps { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 560px) {
  .work-grid { grid-template-columns: minmax(0, 1fr); }
  .work-surface, .work-case { padding: 1rem; }
  .workspace .site-header { padding: 1rem; }
  .workspace main { padding: 1.3rem .9rem 2rem; }
  .work-account { justify-content: start; }
  .work-empty { padding: 1.5rem; }
}
@media (prefers-color-scheme: dark) {
  :root { color-scheme: dark; --ink: #efeee8; --muted: #b7b4ab; --paper: #171918; --panel: #202321; --line: #42463f; --seal: #ffc1b7; --seal-soft: #492724; }
  .workspace { --action: #adc2ff; --action-text: #122344; --focus: #b5c9ff; --subtle: #30352f; --complete-bg: #253e33; --complete-ink: #c0e5ce; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; animation: none !important; }
}

* { box-sizing: border-box; }
body { margin: 0; }
a { color: var(--navy); }
h1, h2, h3 { font-family: "Source Serif 4", Georgia, serif; font-weight: 620; letter-spacing: -0.02em; }
h1 { font-size: 2.1rem; line-height: 1.15; margin: 0 0 0.4rem; }
h2 { font-size: 1.45rem; margin: 0 0 0.6rem; }
h3 { font-size: 1.15rem; margin: 0 0 0.35rem; }

.site-header {
  background: var(--ink);
  color: #f4f0e6;
  padding: 1.1rem 1.5rem 0.9rem;
}
.site-header a { color: inherit; text-decoration: none; }
.brand-kicker {
  font-size: 0.72rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: #d7c7a2;
  margin: 0;
}
.brand { margin: 0.15rem 0 0.8rem; font-size: 1.35rem; }
nav { display: flex; gap: 0.4rem; flex-wrap: wrap; }
nav a {
  color: #f4f0e6;
  text-decoration: none;
  padding: 0.35rem 0.7rem;
  border-radius: 999px;
}
nav a[aria-current="page"] { background: #f4f0e6; color: var(--ink); }

main { max-width: 1080px; margin: 0 auto; padding: 1.6rem 1.25rem 3rem; }
.lede { font-size: 1.12rem; max-width: 68ch; }
.muted { color: var(--muted); }
.grid { display: grid; gap: 0.9rem; }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
@media (max-width: 800px) {
  .grid-3, .grid-2 { grid-template-columns: 1fr; }
}

.card, .papel, .acto {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 1rem 1.1rem;
  box-shadow: var(--shadow);
}
.card p:last-child { margin-bottom: 0; }

.clase {
  display: inline-block;
  font-size: 0.75rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 0.15rem 0.45rem;
  border-radius: 999px;
  font-weight: 700;
}
.clase-observacion { background: var(--seal-soft); color: var(--seal); }
.clase-apertura { background: var(--amber-soft); color: var(--amber); }
.clase-indicio { background: var(--navy-soft); color: var(--navy); }
.clase-sin_observacion { background: var(--pine-soft); color: var(--pine); }
.clase-no_ejecutable, .clase-no_ejecutada { background: #eceae4; color: var(--muted); }

.papel { border-left: 6px solid var(--line); margin-bottom: 0.8rem; }
.papel-observacion { border-left-color: var(--seal); }
.papel-apertura { border-left-color: var(--amber); }
.papel-indicio { border-left-color: var(--navy); }
.papel-sin_observacion { border-left-color: var(--pine); }

.meta { display: flex; gap: 0.8rem; flex-wrap: wrap; color: var(--muted); font-size: 0.92rem; }
dl.cccc { display: grid; grid-template-columns: 8.5rem 1fr; gap: 0.45rem 0.8rem; margin: 1rem 0; }
dl.cccc dt { font-weight: 700; }
dl.cccc dd { margin: 0; }

table { width: 100%; border-collapse: collapse; background: var(--panel); }
th, td { text-align: left; vertical-align: top; padding: 0.55rem 0.6rem; border-bottom: 1px solid var(--line); }
th { font-size: 0.78rem; letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted); }
.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }

form.filtros { display: flex; flex-wrap: wrap; gap: 0.7rem; align-items: end; margin: 1rem 0 1.2rem; }
label { display: flex; flex-direction: column; gap: 0.25rem; font-size: 0.85rem; font-weight: 700; }
input, select {
  font: inherit;
  padding: 0.45rem 0.55rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  min-width: 12rem;
}
button, .button {
  font: inherit;
  background: var(--ink);
  color: #f4f0e6;
  border: 0;
  border-radius: 8px;
  padding: 0.55rem 0.9rem;
  text-decoration: none;
  display: inline-block;
}
.aviso {
  background: var(--amber-soft);
  border: 1px solid #e2cf9f;
  border-radius: 12px;
  padding: 0.8rem 1rem;
}
.fase { margin: 1.4rem 0 0.4rem; }
details { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 0.7rem 0.9rem; margin-bottom: 0.55rem; }
summary { cursor: pointer; font-weight: 700; }
.buscador { width: 100%; max-width: 30rem; margin: 0.4rem 0 0.8rem; }
.oculta { display: none; }
footer.site { max-width: 1080px; margin: 0 auto; padding: 0 1.25rem 2rem; color: var(--muted); font-size: 0.88rem; }

.page-heading { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.metrics { grid-template-columns: repeat(4, minmax(0, 1fr)); margin: 1.3rem 0; }
.table-scroll { max-width: 100%; overflow-x: auto; margin-bottom: 1.5rem; }
.table-scroll table { min-width: 640px; }
.actions { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.actions form { margin: 0; }
.check { flex-direction: row; align-items: center; }
.check input { min-width: auto; width: 1.2rem; height: 1.2rem; }
pre { max-width: 100%; overflow-wrap: anywhere; white-space: pre-wrap; background: var(--paper); border: 1px solid var(--line); border-radius: 8px; padding: 0.8rem; font-size: 0.8rem; }
.empty { padding: 1.2rem; border: 1px dashed var(--line); border-radius: 12px; }
button { cursor: pointer; min-height: 44px; }
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, summary:focus-visible { outline: 3px solid var(--navy); outline-offset: 3px; }
td small, .card small { overflow-wrap: anywhere; }
h2 { margin-top: 1.2rem; }
.card h2 { margin-top: 0; }
@media (max-width: 800px) {
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .page-heading { align-items: flex-start; flex-direction: column; }
  form.filtros label { min-width: 0; max-width: 100%; flex: 1 1 230px; }
  form.filtros input, form.filtros select { min-width: 0; width: 100%; }
  form.filtros .check input { width: 1.2rem; }
  dl.cccc { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto; } }

.agent-form .wide { flex: 1 1 100%; min-width: 0; }
.agent-form select { max-width: 100%; }
textarea { width: 100%; max-width: 100%; font: inherit; padding: .7rem; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); }
textarea:focus-visible { outline: 3px solid var(--navy); outline-offset: 3px; }
button:disabled { opacity: .6; cursor: not-allowed; }

@media print {
  nav, form, button, .buscador, .actions, .no-print { display: none !important; }
  body { background: #fff; }
  article.card, article.papel { break-inside: avoid; box-shadow: none; border: 1px solid #bbb; }
  details { display: none; }
}

.work-paper-content dd { margin: .5rem 0 1.5rem; overflow-wrap: anywhere; }
.work-paper-content dt { margin-top: 1rem; }

/* Recorrido y resultados: la misma jerarquía en todas las etapas. */
.workspace .work-flow-nav { display:flex; flex-wrap:wrap; gap:.35rem; margin:0 0 2rem; border-bottom:1px solid var(--line); padding-bottom:1rem; }
.workspace .work-flow-nav a { padding:.55rem .7rem; text-decoration:none; min-height:44px; display:inline-flex; align-items:center; font-size:.85rem; }
.work-journey { list-style:none; padding:0; display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:1rem; margin:2rem 0; }
.work-journey-step { border:1px solid var(--line); background:var(--panel); border-radius:10px; padding:1.2rem; min-width:0; }
.work-journey-step h2 { margin:.8rem 0 .5rem; }
.work-journey-step p { font-size:.85rem; color:var(--muted); }
.work-journey-step a, .report-document { overflow-wrap:anywhere; }
.report-document { max-width:85ch; }
.report-document h2 { margin-top:2rem; border-top:1px solid var(--line); padding-top:1rem; }
.report-document dd { margin-left:0; }
@media(max-width:850px){.work-journey{grid-template-columns:repeat(2,minmax(0,1fr));}}
@media(max-width:540px){.work-journey{grid-template-columns:1fr;}.workspace .work-flow-nav a{flex:1 1 40%;}}
@media print{.site-header,.work-flow-nav,.skip-link,footer.site{display:none!important}.report-document{max-width:none}h2,h3{break-after:avoid}}

/* Consulta directa de contratos: texto público largo sin desbordamiento. */
.contract-facts { display:grid; grid-template-columns:minmax(100px, 1fr) minmax(0, 3fr); gap:.5rem 1rem; }
.contract-facts dd { margin:0; overflow-wrap:anywhere; min-width:0; }
.contract-facts dt { font-weight:600; overflow-wrap:anywhere; }
.contract-search input, .contract-search select { width:100%; min-width:0; }
@media(max-width:600px) { .contract-facts { grid-template-columns:minmax(0,1fr); } .contract-facts dd { margin-bottom:.6rem; } }

.contract-trace { overflow-wrap:anywhere; }

/* Mantener legible el modo seleccionado sobre la superficie clara. */
.workspace nav[aria-label="Tipo de búsqueda"] a[aria-current] { color: var(--ink); }

.analysis-section { margin:2rem 0; }
.analysis-overview { border-top:4px solid var(--action); }
.analysis-loading { border-left:4px solid var(--action); }
.analysis-signal { margin:1rem 0; border-left:3px solid var(--action); }
.analysis-signal h3 { margin-top:0; }
.analysis-facts p { margin:.7rem 0; }
.analysis-documents { padding-left:1.2rem; }
.analysis-documents li { padding-bottom:1rem; overflow-wrap:anywhere; }
.analysis-documents blockquote { margin:1rem 0; border-left:3px solid var(--line); padding:.8rem; }
.analysis-documents footer { font-size:.8rem; margin-top:.4rem; }
.analysis-next { border-top:3px solid var(--action); }
.set-metrics{display:flex;flex-wrap:wrap;gap:1.5rem;margin:1.25rem 0}.set-metrics>div{display:grid;gap:.4rem;flex:1 1 130px}.set-metrics strong{font-size:2rem;font-variant-numeric:tabular-nums}.set-metrics span{font-size:.88rem}.work-case h3{overflow-wrap:anywhere}
.workspace .work-badge { display: inline-block; min-width: 1.4em; padding: 0 .4em; margin-left: .3em; border-radius: 999px; background: var(--ink); color: var(--panel); font-size: .75rem; font-weight: 700; line-height: 1.4; text-align: center; }
