:root {
  --accent: #b1040e; --accent-dark: #8f1000; --accent-soft: #fbeaea; --gold: #fcbd00;
  --bg: #f7f7f5; --surface: #ffffff; --text: #1a1a1a; --muted: #6b6b6b; --border: #e3e3e0;
  --ok: #1b7f4a; --ok-soft: #e6f4ec; --warn: #9a6700; --warn-soft: #fff4d6; --err: #b1040e; --err-soft: #fbeaea;
  --info: #1d4f91; --info-soft: #e7eef9;
  --radius: 6px; --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root {
    --accent: #e0474f; --accent-dark: #ff6b72; --accent-soft: #3a1618;
    --bg: #151515; --surface: #1e1e1e; --text: #ececec; --muted: #a0a0a0; --border: #333;
    --ok: #5cc28a; --ok-soft: #173325; --warn: #e3b341; --warn-soft: #3a2f10; --err: #ff7b82; --err-soft: #3a1618;
    --info: #7aa7e8; --info-soft: #172a45;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: var(--font); font-size: 15px; line-height: 1.45; background: var(--bg); color: var(--text); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.5rem; margin: 0 0 .25rem; font-weight: 650; letter-spacing: -.01em; }
h2 { font-size: 1.1rem; margin: 1.5rem 0 .6rem; font-weight: 650; }
h3 { font-size: .95rem; margin: 1rem 0 .4rem; font-weight: 650; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.mono { font-family: var(--mono); font-size: .85em; }
.hidden { display: none !important; }

.accent-line { height: 3px; background: linear-gradient(90deg, #8f1000, #b1040e, #fcbd00); }
header.top { background: var(--surface); border-bottom: 1px solid var(--border); }
header.top .inner { max-width: 1200px; margin: 0 auto; padding: .6rem 16px; display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.brand { font-weight: 800; letter-spacing: .04em; color: var(--text); font-size: 1.05rem; }
.brand em { color: var(--accent); font-style: normal; }
nav.main { display: flex; gap: .2rem; flex-wrap: wrap; }
nav.main a { color: var(--muted); padding: .35rem .6rem; border-radius: var(--radius); font-size: .92rem; }
nav.main a.active, nav.main a:hover { color: var(--text); background: var(--bg); text-decoration: none; }
.spacer { flex: 1; }
.userbox { display: flex; align-items: center; gap: .6rem; font-size: .88rem; color: var(--muted); flex-wrap: wrap; }

main { max-width: 1200px; margin: 0 auto; padding: 1.2rem 16px 4rem; }
.crumbs { font-size: .85rem; color: var(--muted); margin-bottom: .4rem; }
.pagehead { display: flex; align-items: flex-start; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.pagehead .actions { margin-left: auto; display: flex; gap: .5rem; flex-wrap: wrap; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem 1.1rem; }
.grid { display: grid; gap: 1rem; }
.grid.cols-2 { grid-template-columns: repeat(auto-fit, minmax(min(320px, 100%), 1fr)); align-items: start; }
.grid.calls { grid-template-columns: repeat(auto-fill, minmax(min(300px, 100%), 1fr)); }
.callcard h3 { margin: .1rem 0 .3rem; font-size: 1.05rem; }
.callcard .meta { font-size: .85rem; color: var(--muted); }

button, .btn { font: inherit; font-size: .9rem; border: 1px solid var(--border); background: var(--surface); color: var(--text);
  padding: .45rem .85rem; border-radius: var(--radius); cursor: pointer; display: inline-flex; align-items: center; gap: .35rem; }
button:hover, .btn:hover { border-color: var(--muted); text-decoration: none; }
button.primary, .btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.primary:hover { background: var(--accent-dark); border-color: var(--accent-dark); }
button.danger { color: var(--err); }
button.link { border: none; background: none; padding: 0; color: var(--accent); }
button:disabled { opacity: .55; cursor: default; }
button.state-ok { background: var(--ok); border-color: var(--ok); color: #fff; }
button.state-err { background: var(--err); border-color: var(--err); color: #fff; }

input, select, textarea { font: inherit; font-size: .92rem; color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius); padding: .45rem .6rem; max-width: 100%; }
input:focus, select:focus, textarea:focus, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
textarea { width: 100%; min-height: 5rem; }
textarea.code { font-family: var(--mono); font-size: .82rem; min-height: 28rem; }
label.field { display: block; margin-bottom: .7rem; }
label.field > span { display: block; font-size: .8rem; color: var(--muted); margin-bottom: .2rem; }
label.field input, label.field select { width: 100%; }
.row { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.filters { display: flex; gap: .5rem; flex-wrap: wrap; margin-bottom: .8rem; }

.tablewrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
table { border-collapse: collapse; width: 100%; font-size: .9rem; }
th, td { text-align: left; padding: .5rem .7rem; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; background: var(--bg); }
tr:last-child td { border-bottom: none; }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: var(--bg); }

.badge { display: inline-block; font-size: .75rem; font-weight: 600; padding: .12rem .5rem; border-radius: 999px;
  background: var(--bg); color: var(--muted); border: 1px solid var(--border); white-space: nowrap; }
.badge.ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.badge.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.badge.err { background: var(--err-soft); color: var(--err); border-color: transparent; }
.badge.info { background: var(--info-soft); color: var(--info); border-color: transparent; }

.notice { padding: .7rem .9rem; border-radius: var(--radius); margin: .6rem 0; font-size: .9rem; }
.notice.warn { background: var(--warn-soft); color: var(--warn); }
.notice.err { background: var(--err-soft); color: var(--err); }
.notice.ok { background: var(--ok-soft); color: var(--ok); }
.notice.info { background: var(--info-soft); color: var(--info); }

dl.kv { display: grid; grid-template-columns: minmax(140px, 32%) 1fr; gap: .35rem 1rem; margin: 0; font-size: .92rem; }
dl.kv dt { color: var(--muted); }
dl.kv dd { margin: 0; overflow-wrap: anywhere; white-space: pre-wrap; }

ul.plain { list-style: none; padding: 0; margin: 0; }
ul.docs li { display: flex; gap: .6rem; align-items: center; padding: .45rem 0; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
ul.docs li:last-child { border-bottom: none; }
ul.docs .name { flex: 1; min-width: 180px; overflow-wrap: anywhere; }
ul.timeline li { padding: .35rem 0; border-bottom: 1px dashed var(--border); font-size: .85rem; }
ul.timeline li:last-child { border-bottom: none; }

.tabs { display: flex; gap: .2rem; border-bottom: 1px solid var(--border); margin: 1rem 0; flex-wrap: wrap; }
.tabs a { padding: .5rem .8rem; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs a.active { color: var(--text); border-bottom-color: var(--accent); text-decoration: none; }
.chips { display: flex; gap: .4rem; flex-wrap: wrap; margin-bottom: .8rem; }

.toast { position: fixed; bottom: 16px; right: 16px; left: 16px; margin-left: auto; max-width: 420px; background: var(--text); color: var(--bg);
  padding: .7rem 1rem; border-radius: var(--radius); font-size: .9rem; z-index: 50; box-shadow: 0 6px 24px rgba(0,0,0,.2); }
.secret { font-family: var(--mono); background: var(--bg); padding: .3rem .5rem; border-radius: 4px; user-select: all; }

/* Login */
body.login { min-height: 100vh; display: flex; flex-direction: column; }
.loginbox { margin: auto; width: calc(100% - 32px); max-width: 380px; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 2rem; }
.loginbox h1 { font-size: 1.8rem; font-weight: 800; letter-spacing: .03em; }
.loginbox h1 em { color: var(--accent); font-style: normal; }
.loginbox p.sub { font-size: .75rem; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); margin: 0 0 1.5rem; }
.loginbox button { width: 100%; justify-content: center; padding: .6rem; }

@media (max-width: 640px) {
  dl.kv { grid-template-columns: 1fr; }
  dl.kv dt { margin-top: .4rem; }
  .pagehead .actions { margin-left: 0; }
}
.tablewrap + .row, .card + .row { margin-top: .8rem; }
a.card { color: inherit; display: block; }
a.card:hover { text-decoration: none; border-color: var(--muted); }
a.card h3 { color: var(--accent); }
.grid + h2 { margin-top: 1.5rem; }
ul.docs .docactions { display: inline-flex; gap: .7rem; align-items: center; white-space: nowrap; margin-left: auto; }
.card > h2:first-child, .card > .row:first-child h2 { margin-top: 0; }
.card > .row:first-child { justify-content: space-between; margin-bottom: .6rem; }
.card > .row:first-child h2 { margin-bottom: 0; }
header.top .inner > * { min-width: 0; }
.grid > * { min-width: 0; }
input[type=file] { width: 100%; max-width: 360px; }

/* ── Editor de convocatorias ─────────────────────────────────────────────── */
.grid.cols-3 { grid-template-columns: repeat(auto-fit, minmax(min(200px, 100%), 1fr)); }
.grid.tight { gap: 0 1rem; }
small.help { display: block; font-size: .78rem; color: var(--muted); margin-top: .2rem; }
label.check { display: inline-flex; align-items: center; gap: .35rem; font-size: .9rem; cursor: pointer; }
label.check input { width: auto; }
.row.nowrap { flex-wrap: nowrap; }
.row.nowrap input { flex: 1; min-width: 0; }
.sections { display: grid; gap: 1rem; }
.sections section { scroll-margin-top: 1rem; }
.secnav { display: flex; gap: .4rem; flex-wrap: wrap; margin-bottom: 1rem; font-size: .88rem; }
.secnav a { padding: .25rem .6rem; border: 1px solid var(--border); border-radius: 999px; color: var(--muted); background: var(--surface); }
.secnav a:hover { color: var(--text); text-decoration: none; border-color: var(--muted); }
.publishbox { background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius); padding: .8rem .9rem; margin: .6rem 0 1rem; }
.publishbox > label.check { margin-bottom: .6rem; }
.checks { display: flex; flex-direction: column; gap: .35rem; margin-bottom: .8rem; }
.listed { margin-bottom: .6rem; }
.itemcard { border: 1px solid var(--border); border-radius: var(--radius); padding: .6rem .8rem; margin-bottom: .6rem; background: var(--surface); }
.itemhead { display: flex; justify-content: space-between; align-items: center; margin-bottom: .3rem; }
.itemcard label.field { margin-bottom: .5rem; }
.rowactions { display: inline-flex; gap: .6rem; white-space: nowrap; }
.rowactions button:disabled { opacity: .25; }
table.edit td { padding: .3rem .4rem; }
table.edit input:not([type=checkbox]) { width: 100%; min-width: 7rem; }
table.edit .w-key input { min-width: 6rem; max-width: 10rem; }
table.edit .w-num input { min-width: 4.5rem; max-width: 6rem; }
table.edit .w-check { text-align: center; }
.savebar { position: sticky; bottom: 0; background: var(--surface); border-top: 1px solid var(--border); padding: .7rem 0; margin-top: 1rem; z-index: 5; }
.savebar .notice { margin-top: 0; }
details > summary { cursor: pointer; color: var(--accent); margin-bottom: .6rem; }
.richtext { white-space: pre-line; overflow-wrap: anywhere; }

/* ── Formulario público ──────────────────────────────────────────────────── */
.narrow { max-width: 820px !important; }
body.apply header.top .inner { gap: .8rem; }
.applyhead { margin: .5rem 0 1rem; }
.applyhead h1 { font-size: 1.7rem; line-height: 1.2; }
.eyebrow { font-size: .78rem; letter-spacing: .08em; text-transform: uppercase; color: var(--accent); margin: 0 0 .3rem; font-weight: 600; }
.deadline { margin: .4rem 0 0; }
.center { text-align: center; }
.applyform { display: grid; gap: 1rem; margin-top: 1rem; }
.applyform div.field { margin-bottom: 1rem; }
.applyform div.field > label:not(.check) { display: block; font-weight: 600; font-size: .92rem; margin-bottom: .25rem; }
.applyform input:not([type=checkbox]):not([type=file]), .applyform select, .applyform textarea { width: 100%; font-size: 1rem; padding: .55rem .65rem; }
.applyform input[type=file] { max-width: 100%; display: block; margin-bottom: .2rem; }
.applyform label.check { align-items: flex-start; font-size: .95rem; }
.applyform label.check input { margin-top: .25rem; flex: none; width: 1.05rem; height: 1.05rem; }
.req { color: var(--accent); }
.fielderr { color: var(--err); font-size: .85rem; min-height: 0; }
.fielderr:not(:empty) { margin-top: .25rem; }
.docfield { padding-bottom: .8rem; border-bottom: 1px dashed var(--border); }
.docfield:last-child { border-bottom: none; }
.hp { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }
.submitbar { display: grid; gap: .6rem; }
.submitbar progress { width: 100%; height: .5rem; accent-color: var(--accent); }
button.big { font-size: 1.05rem; padding: .75rem 1.2rem; justify-content: center; width: 100%; }
.receipt .ref { font-size: 2rem; font-weight: 700; margin: 0 0 1rem; letter-spacing: .02em; }
.receipt .hash { flex-basis: 100%; overflow-wrap: anywhere; font-size: .72rem; }

@media print {
  .noprint, header.top, .accent-line, .toast { display: none !important; }
  body { background: #fff; color: #000; }
  .card { border: none; padding: 0; }
}

.grid.cols-4 { grid-template-columns: repeat(auto-fit, minmax(min(170px, 100%), 1fr)); }
input:disabled, select:disabled, textarea:disabled { background: var(--bg); color: var(--muted); cursor: not-allowed; }
.itemcard > div > .row:first-child { margin-bottom: .35rem; }
.translatebar { margin-bottom: 1rem; }
.translatebar .row { gap: .7rem; }
.translatebar p { margin: .4rem 0 0; }
.sections > * { min-width: 0; }
