:root {
  --ink: #122b3e;
  --muted: #617380;
  --line: #d9e0e4;
  --paper: #f4f6f4;
  --surface: #ffffff;
  --primary: #1f6673;
  --primary-dark: #164c56;
  --gold: #b98a2d;
  --blue-soft: #dcebf0;
  --green-soft: #e2efe8;
  --shadow: 0 14px 38px rgba(18, 43, 62, .08);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.55;
}
a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-dark); }
button, input, select, textarea { font: inherit; }

.site-header {
  min-height: 76px;
  padding: 0 4vw;
  background: #102c3e;
  color: white;
  display: flex;
  align-items: center;
  gap: 2.5rem;
  position: sticky;
  top: 0;
  z-index: 10;
  box-shadow: 0 8px 24px rgba(7, 24, 35, .18);
}
.brand { color: white; display: flex; align-items: center; gap: .8rem; min-width: 220px; }
.brand:hover { color: white; }
.brand-mark {
  width: 45px; height: 45px; display: grid; place-items: center;
  border: 1px solid rgba(255,255,255,.6); border-radius: 50%;
  font-family: Georgia, serif; font-size: .9rem; letter-spacing: .06em;
}
.brand strong, .brand small { display: block; }
.brand strong { font-family: Georgia, serif; font-size: 1.25rem; }
.brand small { color: #bad0d8; font-size: .72rem; letter-spacing: .08em; text-transform: uppercase; }
nav { display: flex; gap: 1.4rem; flex: 1; }
nav a { color: #d8e7ec; font-weight: 650; font-size: .94rem; }
nav a:hover { color: white; }
.user-menu { display: flex; align-items: center; gap: 1rem; font-size: .85rem; }
.user-menu form { margin: 0; }
.user-menu button {
  color: white; background: transparent; border: 1px solid #718a98;
  border-radius: 6px; padding: .35rem .65rem; cursor: pointer;
}

.page-shell { max-width: 1440px; margin: 0 auto; padding: 3rem 4vw 5rem; }
h1, h2, h3 { font-family: Georgia, "Times New Roman", serif; line-height: 1.12; }
h1 { font-size: clamp(2.1rem, 4vw, 4.4rem); margin: .25rem 0 1rem; letter-spacing: -.035em; }
h2 { font-size: 1.55rem; }
.eyebrow {
  margin: 0; color: var(--primary); font-size: .75rem; font-weight: 800;
  letter-spacing: .13em; text-transform: uppercase;
}
.lead { color: #435c6b; font-size: 1.15rem; max-width: 780px; }
.hero, .page-heading {
  display: flex; align-items: flex-end; justify-content: space-between; gap: 2rem;
  margin-bottom: 2.4rem;
}
.hero {
  padding: 2.8rem 3rem; min-height: 290px; color: white;
  background:
    linear-gradient(110deg, rgba(14,48,67,.96), rgba(30,101,113,.82)),
    radial-gradient(circle at 85% 20%, #d1b56d 0 2%, transparent 3%);
  border-radius: 4px 38px 4px 4px;
  box-shadow: var(--shadow);
}
.hero .eyebrow { color: #d3b56c; }
.hero .lead { color: #d9e5e9; }
.hero-actions { display: flex; gap: .7rem; flex-wrap: wrap; }
.button, button {
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 6px; padding: .75rem 1rem; border: 1px solid transparent;
  font-weight: 750; cursor: pointer;
}
.primary { background: var(--primary); color: white; }
.primary:hover { color: white; background: var(--primary-dark); }
.hero .primary { background: #d2aa51; color: #173344; }
.secondary { background: white; color: var(--ink); border-color: var(--line); }

.metrics { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; margin-bottom: 2.5rem; }
.metrics article, .panel, .module-card {
  background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow);
}
.metrics article { padding: 1.3rem 1.5rem; border-top: 4px solid var(--primary); }
.metrics strong, .metrics span, .metrics small { display: block; }
.metrics strong { font: 700 2.2rem Georgia, serif; }
.metrics span { font-weight: 750; }
.metrics small { color: var(--muted); margin-top: .25rem; }
.module-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1.4rem; }
.module-card { padding: 2.3rem; color: var(--ink); min-height: 260px; position: relative; overflow: hidden; }
.module-card:hover { color: var(--ink); transform: translateY(-2px); }
.module-card h2 { font-size: 2rem; margin: 2.5rem 0 .5rem; }
.module-card p { color: var(--muted); max-width: 520px; }
.module-number { position: absolute; top: 1.5rem; right: 1.8rem; font: 700 3.5rem Georgia, serif; color: #dce5e8; }
.expedientes-card { border-left: 6px solid #2b7180; }
.digesto-card { border-left: 6px solid #b58a38; }

.panel { padding: 1.6rem; border-radius: 4px; }
.detail-grid { display: grid; grid-template-columns: 1.35fr .85fr; gap: 1.4rem; margin-bottom: 1.5rem; }
.facts { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: .8rem; }
.facts div { padding: .75rem; background: #f6f8f8; border-left: 3px solid #c6d5da; }
.facts dt { color: var(--muted); font-size: .72rem; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; }
.facts dd { margin: .2rem 0 0; font-weight: 700; }
.document-list { list-style: none; padding: 0; }
.document-list li { padding: .7rem 0; border-bottom: 1px solid var(--line); }
.document-list small, td small { display: block; color: var(--muted); margin-top: .15rem; }
.legal-status { background: var(--green-soft); border-left: 4px solid #3d8061; padding: 1rem; }
.legal-status span, .legal-status small { display: block; }
.legal-status span { font-weight: 800; font-size: 1.1rem; }
.legal-status small { color: #4e6b5c; }

.search-bar { display: flex; gap: .5rem; max-width: 780px; margin-bottom: 1.5rem; }
.search-bar input, .login-card input {
  width: 100%; padding: .8rem .9rem; border: 1px solid #bfcbd0; border-radius: 5px; background: white;
}
.search-bar button { background: var(--primary); color: white; }
.table-wrap { overflow-x: auto; background: white; border: 1px solid var(--line); box-shadow: var(--shadow); }
table { border-collapse: collapse; width: 100%; min-width: 850px; }
th, td { padding: .9rem 1rem; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
th { background: #17384d; color: white; font-size: .76rem; text-transform: uppercase; letter-spacing: .06em; }
tbody tr:hover { background: #f7fafb; }
.status { display: inline-flex; padding: .28rem .55rem; border-radius: 99px; background: color-mix(in srgb, var(--status-color) 14%, white); color: var(--status-color); font-weight: 800; }
.tag { display: inline-flex; padding: .2rem .5rem; border-radius: 99px; background: #e8edef; color: #4c5d66; font-size: .76rem; font-weight: 800; }
.tag.success { background: #dceee4; color: #276342; }

.timeline-section { margin-top: 2rem; }
.section-heading { display: flex; align-items: flex-end; justify-content: space-between; }
.timeline { list-style: none; padding: 0; position: relative; }
.timeline:before { content: ""; position: absolute; left: 160px; top: 0; bottom: 0; width: 2px; background: #c9d6db; }
.timeline li { display: grid; grid-template-columns: 140px 1fr; gap: 40px; padding: 1rem 0; position: relative; }
.timeline li:before { content: ""; position: absolute; left: 153px; top: 1.35rem; width: 12px; height: 12px; border-radius: 50%; background: var(--primary); border: 3px solid var(--paper); }
.timeline time { color: var(--muted); font-size: .85rem; text-align: right; }
.timeline p { margin: .25rem 0; }
.timeline small { color: var(--muted); }
.card-list { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; }
.relation-panel { margin-top: 1.5rem; }

.login-layout { min-height: 70vh; display: grid; grid-template-columns: 1fr 430px; gap: 5rem; align-items: center; }
.login-card { padding: 2rem; }
.login-card label { display: block; font-weight: 750; margin: 1rem 0; }
.login-card input { display: block; margin-top: .35rem; }
.login-card button { width: 100%; margin-top: .8rem; }
.error, .message { padding: .8rem; background: #f7e3e1; color: #7e342e; border-left: 4px solid #a64b43; }
.hidden { display: none !important; }
.muted { color: var(--muted); }

.reception-form { max-width: 1080px; margin: 0 auto; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1.1rem 1.4rem; }
.form-field { min-width: 0; }
.form-field--wide { grid-column: 1 / -1; }
.form-field label { display: block; font-weight: 800; margin-bottom: .4rem; }
.form-field input[type="text"], .form-field input[type="file"], .form-field select, .form-field textarea {
  width: 100%; border: 1px solid #bfcbd0; border-radius: 5px; background: white; padding: .75rem;
}
.form-field input[type="checkbox"] { margin-right: .45rem; }
.form-field small { display: block; color: var(--muted); margin-top: .35rem; }
.field-error { display: block; color: #8b312a; font-weight: 700; margin-top: .3rem; }
.editor-guidance { display: flex; flex-direction: column; padding: 1rem; margin: 1.2rem 0; background: var(--blue-soft); border-left: 4px solid var(--primary); }
.rich-editor-host { min-height: 330px; background: white; }
.rich-editor-host .ql-editor { min-height: 280px; font-size: 1rem; line-height: 1.6; }

.process-card progress, .job-monitor progress, td progress { width: 100%; accent-color: var(--primary); }
.process-notice { background: var(--blue-soft); color: var(--ink); border-left-color: var(--primary); }
.job-monitor { max-width: 900px; margin: 0 auto; }
.job-state { display: flex; justify-content: space-between; align-items: center; gap: 1rem; }
.job-state strong { font: 700 2rem Georgia, serif; }
.job-error { white-space: pre-wrap; overflow-wrap: anywhere; }
.extracted-content { margin-top: 1.5rem; }
.source-chunk { padding: 1.1rem 0; border-top: 1px solid var(--line); scroll-margin-top: 100px; }
.source-chunk header { display: flex; gap: .6rem; justify-content: space-between; color: var(--muted); font-size: .83rem; }
.source-chunk p { white-space: pre-wrap; }
mark { background: #ffe08a; color: #3a2b00; padding: .05em .12em; border-radius: 2px; }
.search-evidence { margin-top: .65rem; padding: .65rem .75rem; background: #edf4f5; border-left: 3px solid var(--primary); font-size: .86rem; }
.search-evidence > a { font-weight: 800; }
.search-evidence > span { float: right; color: var(--muted); text-transform: uppercase; font-size: .68rem; font-weight: 800; }
.search-evidence p { margin: .3rem 0 0; color: #304956; }

@media (max-width: 950px) {
  .site-header { flex-wrap: wrap; padding-block: .8rem; gap: .8rem; }
  nav { order: 3; flex-basis: 100%; overflow-x: auto; padding-bottom: .3rem; }
  .user-menu { margin-left: auto; }
  .hero, .page-heading { align-items: flex-start; flex-direction: column; }
  .metrics { grid-template-columns: 1fr 1fr; }
  .module-grid, .detail-grid, .login-layout { grid-template-columns: 1fr; }
  .card-list { grid-template-columns: 1fr; }
}
@media (max-width: 620px) {
  .page-shell { padding: 1.5rem 1rem 3rem; }
  .hero { padding: 1.8rem; }
  .metrics { grid-template-columns: 1fr; }
  .facts { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .form-field--wide { grid-column: auto; }
  .timeline:before { left: 10px; }
  .timeline li { grid-template-columns: 1fr; gap: .25rem; padding-left: 35px; }
  .timeline li:before { left: 3px; }
  .timeline time { text-align: left; }
}

.agenda-document {
  max-width: 1120px;
  margin: 0 auto;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: clamp(1.25rem, 3vw, 3rem);
}
.agenda-actions { display: flex; justify-content: flex-end; gap: .75rem; margin-bottom: 1.5rem; }
.agenda-header { text-align: center; border-bottom: 3px double var(--ink); padding-bottom: 1.5rem; margin-bottom: 1.75rem; }
.agenda-header h1 { margin: .25rem 0; text-transform: uppercase; letter-spacing: .04em; }
.agenda-header h2 { margin: .25rem 0; }
.agenda-intro { margin-bottom: 2rem; }
.agenda-section { break-inside: avoid; margin: 2rem 0; }
.agenda-section > h2 { border-bottom: 2px solid var(--primary); padding-bottom: .45rem; }
.agenda-table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.agenda-table th, .agenda-table td { border: 1px solid #9ca8ae; padding: .55rem; text-align: left; vertical-align: top; }
.agenda-table th { background: #edf2f4; }
.agenda-item-note { margin: .4rem 0 0; font-style: italic; }
.agenda-empty { color: var(--muted); font-style: italic; }

@media print {
  @page { size: A4 portrait; margin: 16mm 12mm; }
  .no-print, body > header, body > footer, nav { display: none !important; }
  body, main { background: #fff !important; margin: 0 !important; padding: 0 !important; }
  .agenda-document { max-width: none; border: 0; border-radius: 0; padding: 0; }
  .agenda-table { font-size: 9pt; }
  .agenda-section { break-inside: auto; }
  .agenda-table tr { break-inside: avoid; }
}
