:root {
  --ink: #1d2433;
  --ink-soft: #4a5263;
  --muted: #6b7280;
  --paper: #f5f3ee;
  --card: #ffffff;
  --line: #dedad0;
  --primary: #23395d;
  --primary-ink: #ffffff;
  --primary-soft: #e7ecf4;
  --accent: #a8432a;
  --ok: #1f6b45;
  --ok-soft: #e3f1e8;
  --error: #a3202c;
  --error-soft: #fbe9ea;
  --warn-soft: #fbf1dc;
  --radius: 10px;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Noto Serif", Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", sans-serif;
  --mono: ui-monospace, "SFMono-Regular", "DejaVu Sans Mono", Menlo, monospace;
}

* { box-sizing: border-box; }
html { background: var(--paper); color: var(--ink); font: 16px/1.55 var(--sans); }
body { margin: 0; min-height: 100vh; display: flex; flex-direction: column; }
main { flex: 1; padding-block: 2rem 4rem; }
.wrap { width: 100%; max-width: 880px; margin: 0 auto; padding-inline: 1.25rem; }
body.admin .wrap { max-width: 1200px; }
a { color: var(--primary); }
a:hover { color: var(--accent); }
h1, h2, h3 { line-height: 1.25; }
h1 { font: 600 2rem/1.2 var(--serif); margin: .2rem 0 .6rem; letter-spacing: -.01em; }
h2 { font-size: 1.15rem; margin: 0 0 1rem; }
h3 { font-size: .95rem; margin: 1.2rem 0 .4rem; }
code, pre { font-family: var(--mono); font-size: .85em; }
:focus-visible { outline: 3px solid #f0b34a; outline-offset: 2px; }
[hidden] { display: none !important; }

/* Encabezado y pie */
.site-header { background: var(--primary); color: var(--primary-ink); }
.header-inner { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding-block: .8rem; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: .75rem; color: inherit; text-decoration: none; }
.brand:hover { color: inherit; }
.brand-mark { font: 700 .8rem/1 var(--sans); letter-spacing: .12em; border: 2px solid currentColor; padding: .45rem .5rem; border-radius: 6px; }
.brand-text { display: flex; flex-direction: column; line-height: 1.2; }
.brand-inst { font-size: .78rem; opacity: .8; }
.brand-unit { font: 600 1.02rem var(--serif); }
.site-nav { display: flex; gap: 1.1rem; align-items: center; font-size: .92rem; }
.site-nav a { color: inherit; text-decoration: none; opacity: .85; }
.site-nav a:hover, .site-nav a[aria-current] { opacity: 1; text-decoration: underline; text-underline-offset: 4px; }
.site-nav .user { font-size: .8rem; opacity: .7; border-left: 1px solid rgba(255,255,255,.3); padding-left: 1rem; }
.site-footer { border-top: 1px solid var(--line); color: var(--muted); font-size: .8rem; padding-block: 1.2rem; }

/* Bloques */
.intro { margin-bottom: 1.5rem; }
.intro-admin { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; flex-wrap: wrap; }
.kicker { text-transform: uppercase; letter-spacing: .1em; font-size: .75rem; font-weight: 600; color: var(--accent); margin: 0; }
.lead { font-size: 1.05rem; color: var(--ink-soft); max-width: 60ch; }
.muted { color: var(--muted); }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.4rem 1.5rem; margin-bottom: 1.25rem; }
.muted-card { background: transparent; }
.muted-card ul { margin: 0; padding-left: 1.2rem; color: var(--ink-soft); }
.form-cards { list-style: none; padding: 0; margin: 0 0 1.25rem; }
.form-card { display: flex; flex-direction: column; gap: 1rem; border-left: 4px solid var(--primary); }
.form-card h2 { font: 600 1.35rem var(--serif); margin-bottom: .4rem; }
.form-card p { margin: 0 0 .4rem; }
.actions { display: flex; gap: .6rem; flex-wrap: wrap; }
.prewrap { white-space: pre-wrap; }
ul.plain { list-style: none; margin: 0; padding: 0; }
ul.plain li + li { margin-top: .25rem; }
.breadcrumb { margin: 0 0 .5rem; font-size: .9rem; }

/* Botones */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; font: 600 .95rem var(--sans);
       border-radius: 8px; padding: .6rem 1.1rem; border: 1px solid transparent; cursor: pointer; text-decoration: none; }
.btn-primary { background: var(--primary); color: var(--primary-ink); }
.btn-primary:hover { background: #1a2b47; color: var(--primary-ink); }
.btn-primary:disabled { opacity: .45; cursor: not-allowed; }
.btn-ghost { background: transparent; color: var(--primary); border-color: currentColor; }
.btn-ghost:hover { background: var(--primary-soft); color: var(--primary); }
.btn-lg { padding: .8rem 1.4rem; font-size: 1.02rem; }
.btn-add { background: none; border: 1px dashed var(--line); color: var(--primary); border-radius: 8px; padding: .45rem .8rem;
           font: 600 .88rem var(--sans); cursor: pointer; margin-top: .5rem; }
.btn-add:hover { border-color: var(--primary); }
.btn-remove { background: none; border: none; color: var(--muted); font-size: 1.4rem; line-height: 1; cursor: pointer; padding: .3rem .5rem; border-radius: 6px; align-self: center; }
.btn-remove:hover { color: var(--error); background: var(--error-soft); }

/* Formulario */
.form-section h2 { display: flex; align-items: center; gap: .7rem; font: 600 1.25rem var(--serif); border-bottom: 1px solid var(--line); padding-bottom: .8rem; }
.step { display: inline-grid; place-items: center; width: 1.8rem; height: 1.8rem; border-radius: 50%; background: var(--primary-soft);
        color: var(--primary); font: 700 .85rem var(--sans); flex: none; }
.fields { display: grid; gap: 1.15rem; }
.field > label, .field legend { display: block; font-weight: 600; font-size: .93rem; margin-bottom: .3rem; padding: 0; }
.field fieldset { border: none; margin: 0; padding: 0; min-width: 0; }
.req { color: var(--accent); margin-left: .15rem; }
.help { color: var(--muted); font-size: .84rem; margin: -.1rem 0 .45rem; }
input[type=text], input[type=email], input[type=date], select, textarea {
  width: 100%; font: inherit; font-size: .95rem; color: var(--ink); background: #fff;
  border: 1px solid #c9c4b8; border-radius: 7px; padding: .55rem .7rem; }
textarea { resize: vertical; line-height: 1.5; }
input:focus, select:focus, textarea:focus { border-color: var(--primary); outline: 2px solid var(--primary-soft); outline-offset: 0; }
input:disabled, select:disabled, textarea:disabled { background: #f1efe9; }
input[type=file] { font: inherit; font-size: .9rem; padding: .5rem; border: 1px dashed #c9c4b8; border-radius: 7px; width: 100%; background: #fcfbf8; }
.counter { font-size: .78rem; color: var(--muted); margin: .25rem 0 0; text-align: right; }
.counter-short { color: var(--accent); }
.has-error input, .has-error select, .has-error textarea { border-color: var(--error); background: #fffafa; }
.error { color: var(--error); font-size: .86rem; font-weight: 600; margin: .35rem 0 0; }
.error::before { content: "⚠ "; }

.row-group { display: grid; grid-template-columns: 1fr 1fr 1.3fr auto; gap: .6rem; align-items: end; padding: .7rem; background: #faf9f6; border: 1px solid var(--line); border-radius: 8px; }
.row-group + .row-group { margin-top: .5rem; }
.row-group .sub { display: flex; flex-direction: column; gap: .2rem; font-size: .8rem; font-weight: 600; color: var(--ink-soft); }
.row-group .sub input { font-weight: 400; }
.row-group.fixed { grid-template-columns: 1fr 1fr 1.3fr; }
.list-rows { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: .5rem; }
.row-item { display: flex; gap: .2rem; }

.radios .radio { display: flex; gap: .7rem; align-items: flex-start; padding: .6rem .75rem; border: 1px solid var(--line); border-radius: 8px; margin-bottom: .4rem; cursor: pointer; }
.radios .radio:hover { border-color: var(--primary); }
.radios .radio:has(input:checked) { border-color: var(--primary); background: var(--primary-soft); }
.radio input { margin-top: .3rem; }
.radio span { display: flex; flex-direction: column; font-size: .93rem; }
.radio small { color: var(--ink-soft); font-size: .83rem; }
.check { display: flex; gap: .7rem; align-items: flex-start; font-size: .92rem; font-weight: 400 !important; cursor: pointer; }
.check input { margin-top: .3rem; width: 1.05rem; height: 1.05rem; flex: none; }
.license-text { margin-top: 1.2rem; border-top: 1px solid var(--line); padding-top: 1rem; font-size: .88rem; color: var(--ink-soft); }
.license-text summary { cursor: pointer; font-weight: 600; color: var(--primary); }
.license-text .prewrap { margin-top: .8rem; background: #faf9f6; padding: 1rem; border-radius: 8px; }
.submit-bar { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; padding: 1rem 0; }
.submit-bar p { margin: 0; max-width: 45ch; font-size: .9rem; }

/* Avisos */
.alert { border-radius: var(--radius); padding: .9rem 1.1rem; margin-bottom: 1.25rem; border: 1px solid; }
.alert ul { margin: .4rem 0 0; padding-left: 1.2rem; columns: 2 16rem; column-gap: 2rem; }
.alert:focus { outline: none; }
.alert-error { background: var(--error-soft); border-color: #eab7bb; color: #6d1219; }
.alert-ok { background: var(--ok-soft); border-color: #b5d9c3; color: #134a2e; }
.success-card { border-top: 5px solid var(--ok); }
.error-card { border-top: 5px solid var(--error); }
.tramite { font-family: var(--mono); background: var(--primary-soft); padding: .1rem .45rem; border-radius: 5px; color: var(--primary); }
.steps { margin: 0; padding-left: 1.3rem; }
.steps li { margin-bottom: .4rem; }
dl.summary { display: grid; grid-template-columns: minmax(150px, 30%) 1fr; gap: .45rem 1.2rem; margin: 0; font-size: .93rem; }
dl.summary dt { color: var(--muted); font-size: .85rem; }
dl.summary dd { margin: 0; overflow-wrap: anywhere; }

/* Bandeja */
.tabs { display: flex; gap: .3rem; flex-wrap: wrap; margin-bottom: 1rem; }
.tabs a { text-decoration: none; padding: .4rem .8rem; border-radius: 999px; font-size: .88rem; color: var(--ink-soft); border: 1px solid transparent; }
.tabs a:hover { border-color: var(--line); }
.tabs a[aria-current] { background: var(--primary); color: #fff; }
.count { font-size: .75rem; opacity: .75; margin-left: .2rem; }
.table-wrap { overflow-x: auto; padding: 0; }
.table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.table th { text-align: left; font-size: .75rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: .8rem 1rem; border-bottom: 1px solid var(--line); background: #faf9f6; }
.table td { padding: .75rem 1rem; border-bottom: 1px solid #eeebe4; vertical-align: top; }
.table tr:last-child td { border-bottom: none; }
.table .empty { text-align: center; color: var(--muted); padding: 2rem; }
.nowrap { white-space: nowrap; }
.tick { color: var(--ok); font-weight: 700; }
.badge { display: inline-block; font: 600 .75rem var(--sans); padding: .2rem .6rem; border-radius: 999px; white-space: nowrap; vertical-align: middle; letter-spacing: .01em; }
.badge-received { background: #eceff3; color: #3a4556; }
.badge-pending_review { background: var(--warn-soft); color: #7a5200; }
.badge-in_evaluation { background: #efe9f6; color: #5b3a86; }
.badge-at_node { background: #e2f0f1; color: #1d5f66; }
.badge-verified { background: var(--ok-soft); color: var(--ok); }
.badge-rejected, .badge-node_observed { background: var(--error-soft); color: var(--error); }
.badge-dspace_ready { background: var(--primary-soft); color: var(--primary); }
.badge-imported { background: var(--primary); color: #fff; }
.intro-admin h1 .badge { font-size: .8rem; margin-left: .4rem; }
.exports { display: flex; gap: .8rem; flex-wrap: wrap; font-size: .85rem; margin-bottom: 1rem; }
.export-form { margin: 0; }

.detail-grid { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 1.25rem; align-items: start; }
.detail-side { position: sticky; top: 1rem; }
.detail-side .card { padding: 1.1rem 1.2rem; }
.detail-side h2 { font-size: 1rem; }
.stack { display: grid; gap: .7rem; }
.stack label { font-size: .88rem; font-weight: 600; display: grid; gap: .3rem; }
.dest { display: inline-flex; gap: .2rem; margin-left: .2rem; }
.dest i { font: 600 .6rem var(--sans); font-style: normal; text-transform: uppercase; letter-spacing: .05em; padding: .05rem .3rem; border-radius: 4px; background: #eceff3; color: #56606f; }
.dest i.dest-dspace { background: var(--primary-soft); color: var(--primary); }
.dest i.dest-pdf { background: #f6e8e2; color: var(--accent); }
pre.code { background: #1f2430; color: #e7e9ee; padding: 1rem; border-radius: 8px; overflow-x: auto; font-size: .78rem; line-height: 1.5; margin: 0; }
details summary { cursor: pointer; font-weight: 600; }
details pre.code { margin-top: .8rem; }
.audit { list-style: none; margin: 0; padding: 0; font-size: .82rem; }
.audit li { padding: .5rem 0; border-bottom: 1px solid #eeebe4; display: grid; gap: .1rem; }
.audit li:last-child { border-bottom: none; }
.audit-when { color: var(--muted); font-size: .75rem; }
.audit-what { font-weight: 600; }
.audit-detail { color: var(--ink-soft); overflow-wrap: anywhere; white-space: pre-line; }

@media (max-width: 900px) {
  .detail-grid { grid-template-columns: 1fr; }
  .detail-side { position: static; }
}
@media (max-width: 640px) {
  h1 { font-size: 1.6rem; }
  .card { padding: 1.1rem; }
  .row-group, .row-group.fixed { grid-template-columns: 1fr; }
  .row-group .btn-remove { justify-self: end; }
  dl.summary { grid-template-columns: 1fr; gap: .1rem; }
  dl.summary dd { margin-bottom: .6rem; }
}

/* Datos que carga la Secretaría de Posgrado */
.card-staff { border-left: 4px solid var(--primary); }
.small { font-size: .8rem; font-weight: normal; }
.intro-admin > .btn { align-self: center; }
