/* DuaForge · estilos de la aplicación (sin dependencias) */
:root {
  --bg: #f4f6f9; --panel: #ffffff; --ink: #1c2330; --muted: #5e6878; --line: #dde2ea; --soft: #eef1f6;
  --brand: #c1560a; --brand-ink: #ffffff; --brand-soft: #fbe9dc;
  --sb-bg: var(--brand); --sb-bg-hover: rgba(255,255,255,.15); --sb-ink: #ffffff; --sb-muted: #ffe0c2; --sb-active-bg: #ffffff; --sb-active-ink: var(--brand);
  --ok: #1d7a46; --ok-soft: #e3f4ea; --warn: #9a6200; --warn-soft: #fdf1dc; --err: #b3261e; --err-soft: #fbe6e4; --info: #245d8f; --info-soft: #e4eef8;
  --radius: 10px; --shadow: 0 1px 2px rgba(20, 30, 50, .06), 0 2px 8px rgba(20, 30, 50, .04);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12161d; --panel: #1a2029; --ink: #e5e9f0; --muted: #9aa4b4; --line: #2c3441; --soft: #222a35;
    --brand: #f0a05c; --brand-ink: #241207; --brand-soft: #3a2311;
    --sb-bg: var(--brand); --sb-bg-hover: rgba(0,0,0,.10); --sb-ink: #2a1206; --sb-muted: #6b3312; --sb-active-bg: #2a1206; --sb-active-ink: #f6b877;
    --ok: #5cc98a; --ok-soft: #173024; --warn: #e8b35a; --warn-soft: #33281a; --err: #f08378; --err-soft: #3a1f1d; --info: #7fb4e6; --info-soft: #1b2a3a;
    --shadow: none; color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 15px/1.5 var(--font); color: var(--ink); background: var(--bg); }
a { color: var(--brand); }
h1 { font-size: 1.45rem; margin: 0 0 .25rem; line-height: 1.25; }
h2 { font-size: 1.08rem; margin: 0 0 .6rem; }
h3 { font-size: .98rem; margin: 1rem 0 .4rem; }
p { margin: .3rem 0 .7rem; }
code { background: var(--soft); padding: 0 .3em; border-radius: 4px; font-size: .9em; word-break: break-all; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.skip { position: absolute; left: -999px; top: 0; background: var(--brand); color: var(--brand-ink); padding: .5rem 1rem; z-index: 99; }
.skip:focus { left: 0; }
:focus-visible { outline: 3px solid var(--brand); outline-offset: 2px; }
.muted { color: var(--muted); } .small { font-size: .86rem; } .normal { font-weight: 400; } .nowrap { white-space: nowrap; }
.right { text-align: right; } .c { text-align: center; } .mt { margin-top: 1rem; }
.err-text { color: var(--err); } .warn-text { color: var(--warn); font-weight: 600; }

/* Barra superior y navegación */
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: .75rem; padding: .55rem 1rem; background: var(--panel); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: baseline; gap: .4rem; font-weight: 700; font-size: 1.1rem; color: var(--ink); text-decoration: none; }
.brand small { font-weight: 500; color: var(--muted); font-size: .78rem; }
.brand.big { font-size: 1.6rem; justify-content: center; }
.logo-mark { display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto; width: 1.5em; height: 1.5em; border-radius: 6px; background: var(--brand); color: #fff; font-weight: 800; font-size: .85em; line-height: 1; }
.brand.big .logo-mark { width: 2.3em; height: 2.3em; font-size: 1.3em; border-radius: 9px; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: .75rem; }
.user { display: flex; flex-direction: column; text-align: right; text-decoration: none; color: var(--ink); font-size: .88rem; line-height: 1.2; }
.user small { color: var(--muted); }
.curso-sel select { font-weight: 600; }
.navtoggle { display: none; background: none; border: 1px solid var(--line); color: var(--ink); border-radius: 8px; font-size: 1.1rem; padding: .2rem .55rem; cursor: pointer; }
.shell { display: grid; grid-template-columns: 232px 1fr; min-height: calc(100vh - 54px); }
.sidebar { background: var(--sb-bg); border-right: 0; padding: .8rem .6rem 2rem; position: sticky; top: 54px; height: calc(100vh - 54px); overflow-y: auto; }
.navgroup { margin-bottom: .8rem; }
.navtitle { font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--sb-muted); padding: .2rem .6rem; }
.sidebar a { display: block; padding: .38rem .6rem; border-radius: 7px; color: var(--sb-ink); text-decoration: none; font-size: .92rem; }
.sidebar a:hover { background: var(--sb-bg-hover); }
.sidebar a.active { background: var(--sb-active-bg); color: var(--sb-active-ink); font-weight: 600; }
.navfoot { font-size: .75rem; color: var(--sb-muted); padding: .6rem; }
.main { padding: 1.2rem 1.4rem 3rem; min-width: 0; max-width: 1500px; }

/* Bloques */
.pagehead { display: flex; flex-wrap: wrap; gap: .8rem; align-items: flex-start; justify-content: space-between; margin-bottom: 1rem; }
.pagehead .actions, .actions { display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; }
.crumbs { margin: 0 0 .2rem; font-size: .85rem; } .crumbs a { text-decoration: none; }
.intro { color: var(--muted); max-width: 70em; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.1rem; margin-bottom: 1rem; box-shadow: var(--shadow); min-width: 0; }
.card.narrow { max-width: 520px; }
.cardhead { display: flex; gap: .8rem; justify-content: space-between; align-items: flex-start; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; align-items: start; }
.grid2.wide-left { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.grid2 > * { min-width: 0; }
.cards, .cards3 { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 1rem; }
.cards3 { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.linkcard { text-decoration: none; color: inherit; display: block; } .linkcard:hover { border-color: var(--brand); }
.empty { color: var(--muted); text-align: center; padding: 1.2rem; }

/* KPIs */
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(165px, 1fr)); gap: .75rem; margin-bottom: 1rem; }
.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: .75rem .9rem; box-shadow: var(--shadow); }
.kpi .kv { font-size: 1.45rem; font-weight: 700; line-height: 1.2; font-variant-numeric: tabular-nums; }
.kpi .kv small { font-size: .85rem; color: var(--muted); font-weight: 500; }
.kpi .kl { color: var(--muted); font-size: .82rem; }
.kpi.bad { border-left: 4px solid var(--err); } .kpi.warn { border-left: 4px solid var(--warn); } .kpi.good { border-left: 4px solid var(--ok); }

/* Botones y formularios */
.btn { display: inline-flex; align-items: center; gap: .3rem; background: var(--brand); color: var(--brand-ink); border: 1px solid var(--brand); border-radius: 8px; padding: .45rem .9rem; font: inherit; font-weight: 600; font-size: .92rem; cursor: pointer; text-decoration: none; line-height: 1.2; }
.btn:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; color: var(--brand); border-color: var(--line); }
.btn.ghost:hover { background: var(--soft); }
.btn.danger { background: transparent; color: var(--err); border-color: var(--err-soft); }
.btn.danger:hover { background: var(--err-soft); }
.btn.ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn.warn { background: var(--warn); border-color: var(--warn); color: #fff; }
.btn.sm { padding: .25rem .55rem; font-size: .82rem; }
.btn.block { width: 100%; justify-content: center; padding: .65rem; }
.btn[disabled] { opacity: .45; cursor: not-allowed; }
.link { background: none; border: none; color: var(--brand); cursor: pointer; font: inherit; font-size: .85rem; padding: 0 .2rem; text-decoration: underline; }
.link.danger { color: var(--err); }
input, select, textarea { font: inherit; color: var(--ink); background: var(--panel); border: 1px solid var(--line); border-radius: 7px; padding: .42rem .55rem; max-width: 100%; }
input:focus, select:focus, textarea:focus { border-color: var(--brand); outline: none; box-shadow: 0 0 0 3px var(--brand-soft); }
input[readonly] { background: var(--soft); }
textarea { width: 100%; resize: vertical; }
fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
fieldset[disabled] { opacity: .85; }
legend { font-weight: 600; font-size: .9rem; margin-bottom: .3rem; }
.form .field, .field { display: flex; flex-direction: column; gap: .25rem; margin-bottom: .7rem; }
.field label { font-weight: 600; font-size: .88rem; }
.field input:not([type=checkbox]):not([type=radio]), .field select { width: 100%; }
.formgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 0 1rem; }
.formgrid .wide { grid-column: 1 / -1; }
.formsection { grid-column: 1 / -1; font-size: .95rem; border-bottom: 1px solid var(--line); padding-bottom: .3rem; margin: .8rem 0 .6rem; color: var(--brand); }
.formactions { display: flex; gap: .5rem; margin-top: .5rem; flex-wrap: wrap; }
.help { color: var(--muted); font-size: .8rem; }
.linklike { background: none; border: none; padding: 0; margin: 0; color: var(--brand); text-decoration: underline; cursor: pointer; font: inherit; }
.linklike:disabled { color: var(--muted); text-decoration: none; cursor: default; }
label.check { display: flex; gap: .45rem; align-items: flex-start; font-weight: 400; cursor: pointer; }
label.check input { margin-top: .25rem; }
.checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: .2rem .8rem; }
.checks.scroll { max-height: 190px; overflow-y: auto; grid-template-columns: 1fr; border: 1px solid var(--line); border-radius: 7px; padding: .4rem .6rem; }
.niveles { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: .4rem 1rem; }
.niveles label { display: flex; justify-content: space-between; align-items: center; gap: .5rem; font-size: .9rem; }
.inline { display: inline; }
.inlineform { display: flex; flex-wrap: wrap; gap: .5rem; align-items: flex-end; margin-top: .6rem; }
.inlineform label { display: flex; flex-direction: column; font-size: .8rem; font-weight: 600; gap: .15rem; }
.inlineform fieldset.days { display: flex; gap: .15rem; }
.inlineform fieldset.days label { flex-direction: column; align-items: center; font-weight: 400; }
.toolbar, .filters { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; margin-bottom: .7rem; }
.filters label { display: flex; align-items: center; gap: .35rem; font-size: .85rem; color: var(--muted); }
.filters select { max-width: 280px; }
.tablefilter { min-width: 240px; }
.stateflow { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .8rem; padding-top: .8rem; border-top: 1px solid var(--line); }
details.pop { display: inline-block; position: relative; }
details.pop.inline { display: inline; }
details.pop > summary { list-style: none; cursor: pointer; display: inline-flex; }
details.pop > summary::-webkit-details-marker { display: none; }
summary.link { color: var(--brand); font-size: .85rem; text-decoration: underline; }
.popform { display: flex; flex-direction: column; gap: .4rem; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: .7rem; margin-top: .4rem; min-width: min(420px, 80vw); box-shadow: 0 6px 24px rgba(0,0,0,.12); position: relative; z-index: 5; }
.popform label { display: flex; flex-direction: column; font-size: .82rem; font-weight: 600; gap: .15rem; }

/* Asistente IA */
.btn.ia { background: #6a4bc4; border-color: #6a4bc4; color: #fff; }
.link.ia { color: #6a4bc4; font-weight: 600; text-decoration: none; }
@media (prefers-color-scheme: dark) { .btn.ia { background: #9d85f0; border-color: #9d85f0; color: #140c2a; } .link.ia { color: #b7a6f5; } }
.ia-out h3 { margin-top: 1rem; color: var(--brand); } .ia-out ul, .ia-out ol { padding-left: 1.3rem; } .ia-out li { margin-bottom: .3rem; }
form[data-ia].busy button { opacity: .6; cursor: progress; }
.mb { margin-bottom: .5rem; }

/* Tablas */
.tablewrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.table th, .table td { padding: .5rem .55rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.table thead th { font-size: .78rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); background: var(--soft); position: sticky; top: 0; }
.table th.right, .table td.right { text-align: right; } .table .c { text-align: center; }
.table tfoot th { background: var(--soft); }
.table.compact th, .table.compact td { padding: .32rem .45rem; }
.table tbody tr:hover { background: color-mix(in srgb, var(--soft) 60%, transparent); }
.table td.detail { max-width: 460px; font-size: .82rem; color: var(--muted); word-break: break-word; }
.row-err td { background: var(--err-soft); } .row-warn td:first-child { box-shadow: inset 3px 0 var(--err); } .row-muted td { opacity: .55; }
.grouprow th { background: var(--brand-soft); color: var(--brand); font-size: .85rem; }
.pager { display: flex; gap: .5rem; margin-top: .6rem; }

/* Etiquetas */
.badge { display: inline-block; padding: .05rem .45rem; border-radius: 999px; font-size: .74rem; font-weight: 600; background: var(--soft); color: var(--muted); white-space: nowrap; vertical-align: middle; }
.badge.ok { background: var(--ok-soft); color: var(--ok); } .badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.err { background: var(--err-soft); color: var(--err); } .badge.info { background: var(--info-soft); color: var(--info); }
.flash { padding: .6rem .85rem; border-radius: 8px; margin-bottom: .75rem; border: 1px solid transparent; }
.flash.ok { background: var(--ok-soft); color: var(--ok); } .flash.err { background: var(--err-soft); color: var(--err); } .flash.warn { background: var(--warn-soft); color: var(--warn); }

/* Alertas */
.valdet > summary { cursor: pointer; list-style: none; display: flex; align-items: center; gap: .4rem; flex-wrap: wrap; padding: .15rem 0; }
.valdet > summary::-webkit-details-marker { display: none; }
.valdet > summary::before { content: '▸'; color: var(--muted); }
.valdet[open] > summary::before { content: '▾'; }
.valdet > .alerts { margin-top: .7rem; }
.alerts { list-style: none; margin: 0; padding: 0; }
.alert { display: flex; gap: .55rem; padding: .5rem .6rem; border-radius: 8px; margin-bottom: .35rem; font-size: .9rem; }
.alert.error { background: var(--err-soft); } .alert.aviso { background: var(--warn-soft); } .alert.info, .alert.ok { background: var(--soft); }
.alert .ico { flex: 0 0 auto; }
.why summary { cursor: pointer; font-size: .8rem; color: var(--muted); }
.why p { font-size: .84rem; margin: .2rem 0; }

/* Barras de progreso */
.bar { position: relative; height: 8px; background: var(--soft); border-radius: 99px; min-width: 70px; margin: .2rem 0; }
.bar span { position: absolute; left: 0; top: 0; bottom: 0; background: var(--brand); border-radius: 99px; }
.bar span.err { background: var(--err); } .bar span.warn { background: var(--warn); }
.bar i { position: absolute; top: -3px; bottom: -3px; width: 2px; background: var(--ink); opacity: .55; }
.hbars { list-style: none; padding: 0; margin: 0; }
.hbars li { display: grid; grid-template-columns: minmax(0, 1.4fr) 1fr 2rem; gap: .5rem; align-items: center; font-size: .86rem; margin-bottom: .3rem; }
.hbars .lbl { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbar { height: 10px; background: var(--soft); border-radius: 99px; position: relative; }
.hbar span { position: absolute; left: 0; top: 0; bottom: 0; background: var(--brand); border-radius: 99px; }
.hbars .val { text-align: right; font-variant-numeric: tabular-nums; }
.occ, .planlist { list-style: none; padding: 0; margin: 0; }
.occ li, .planlist li { display: flex; flex-wrap: wrap; justify-content: space-between; gap: .4rem; padding: .35rem 0; border-bottom: 1px solid var(--line); font-size: .88rem; }

/* Currículo */
.tabs { display: flex; flex-wrap: wrap; gap: .3rem; margin-bottom: .8rem; }
.tab { padding: .4rem .8rem; border: 1px solid var(--line); border-radius: 8px; text-decoration: none; color: var(--ink); background: var(--panel); font-weight: 600; font-size: .9rem; }
.tab small { color: var(--muted); font-weight: 400; }
.tab.active { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); } .tab.active small { color: inherit; opacity: .8; }
.ra h2 { font-size: .98rem; }
.ces { margin: .3rem 0 .6rem; padding-left: 1.1rem; font-size: .9rem; }
.ces li { margin-bottom: .25rem; }

/* Matriz */
.sticky-sum { position: sticky; top: 62px; z-index: 6; display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; font-size: .92rem; }
.sticky-sum .sum b { font-variant-numeric: tabular-nums; }
.summsg { font-weight: 600; }
.summsg.err { color: var(--err); } .summsg.ok { color: var(--ok); } .summsg.warn { color: var(--warn); }
.ra-grid { display: grid; grid-template-columns: minmax(0, 3fr) 110px 110px minmax(150px, 1fr); gap: .7rem; align-items: end; margin-bottom: .5rem; }
.ra-grid label, label.block { display: flex; flex-direction: column; font-size: .78rem; font-weight: 600; color: var(--muted); gap: .15rem; }
.ra-desc { font-size: .92rem; align-self: start; }
input.num { text-align: right; font-variant-numeric: tabular-nums; width: 100%; }
.ces-table { margin-top: .5rem; }
.ces-table td:first-child { font-size: .86rem; }
.ra-quick { display: flex; align-items: center; gap: .4rem; flex-wrap: wrap; margin: .3rem 0 .5rem; }
.btn.ghost.active { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
.sticky-actions { position: sticky; bottom: 0; background: var(--bg); padding: .6rem 0; border-top: 1px solid var(--line); }

/* PFI */
.pfi-ra { border-top: 1px solid var(--line); padding: .5rem 0; }
.pfi-ra .hours { display: inline-flex; gap: .4rem; align-items: center; margin: .3rem 0 .3rem 1.6rem; font-size: .85rem; }
.pfi-ces { margin-left: 1.6rem; display: grid; gap: .1rem; }
.dl { display: grid; grid-template-columns: max-content 1fr; gap: .25rem .9rem; margin: 0; font-size: .9rem; }
.dl dt { color: var(--muted); } .dl dd { margin: 0; }
.biblio { max-height: 260px; overflow-y: auto; padding-left: 0; list-style: none; }
.sug { padding-left: 1.2rem; margin: 0; }
.sug li { padding: .45rem 0; border-bottom: 1px solid var(--line); }
.sughead { display: flex; justify-content: space-between; gap: .5rem; }
.score { font-weight: 700; background: var(--brand-soft); color: var(--brand); border-radius: 6px; padding: 0 .4rem; font-size: .82rem; }
.pro { color: var(--ok); } .con { color: var(--err); }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { padding: .5rem 0 .5rem .8rem; border-left: 2px solid var(--line); margin-left: .3rem; font-size: .9rem; }
.steps li { margin-bottom: .3rem; }

/* Gantt */
.gantt { padding: .5rem 0; overflow-x: auto; }
.g-row { display: grid; grid-template-columns: 260px minmax(560px, 1fr); border-bottom: 1px solid var(--line); min-height: 30px; align-items: center; }
.g-label { padding: .25rem .8rem; font-size: .84rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; position: sticky; left: 0; background: var(--panel); z-index: 2; }
.g-track { position: relative; height: 30px; background: repeating-linear-gradient(90deg, transparent 0, transparent calc(100%/12 - 1px), var(--line) calc(100%/12 - 1px), var(--line) calc(100%/12)); background: none; }
.g-head { background: var(--soft); font-weight: 600; position: sticky; top: 0; z-index: 3; }
.g-head .g-label { background: var(--soft); }
.g-month { position: absolute; top: 6px; font-size: .74rem; color: var(--muted); border-left: 1px solid var(--line); padding-left: 3px; height: 100vh; }
.g-today { position: absolute; top: 0; width: 2px; background: var(--err); height: 100vh; z-index: 1; }
.g-bar { position: absolute; top: 6px; height: 18px; border-radius: 5px; font-size: .72rem; color: #fff; overflow: hidden; white-space: nowrap; text-decoration: none; padding: 0 5px; line-height: 18px; z-index: 2; }
.g-bar.periodo { background: var(--brand-soft); border: 1px dashed var(--brand); }
.g-periodo { background: color-mix(in srgb, var(--brand-soft) 40%, transparent); }
.g-bar.c1 { background: #2f6db5; } .g-bar.c2 { background: #2a8a6a; } .g-bar.c3 { background: #8a5cc2; } .g-bar.c4 { background: #c0782a; }
.g-bar.c5 { background: #3a8fa6; } .g-bar.c6 { background: #a24d7a; } .g-bar.c7 { background: #5c7a2a; } .g-bar.c8 { background: #6a6f80; }
.g-bar.tentative { background-image: repeating-linear-gradient(45deg, rgba(255,255,255,.28) 0 6px, transparent 6px 12px); }
.g-bar.conflict { background: var(--err) !important; outline: 2px solid var(--err); }
.g-bar.margen { background: none; border: 1px dashed var(--muted); pointer-events: none; }
.months { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: .8rem; }
.month h3 { margin: 0 0 .4rem; }
.mgrid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; font-size: .78rem; text-align: center; }
.mgrid .dn { color: var(--muted); font-weight: 600; }
.mgrid .day { padding: .25rem 0; border-radius: 4px; }
.mgrid .day.we { color: var(--muted); background: var(--soft); } .mgrid .day.fest { text-decoration: line-through; color: var(--err); }
.mgrid .day.on { background: color-mix(in srgb, var(--brand) calc(var(--i) * 100%), transparent); color: #fff; font-weight: 600; }
.mgrid .day.periodo { box-shadow: inset 0 0 0 2px var(--brand); }
.mgrid .day.periodo.on { box-shadow: inset 0 0 0 2px var(--ink); }

/* Calendario visual de festivos (centro y empresas): sustituye el textarea plano */
.festcal { margin-top: .3rem; max-width: 340px; }
.festcal-head { display: flex; align-items: center; gap: .35rem; margin-bottom: .5rem; flex-wrap: wrap; }
.festcal-head button { flex: none; padding: .3rem .55rem; line-height: 1; }
.festcal-head select { width: auto; flex: 1 1 auto; min-width: 5.5rem; padding: .3rem .4rem; }
.festcal-head .festcal-hoy { margin-left: auto; }
.festcal-grid { max-width: 320px; }
.festcal-grid .day { border: 1px solid transparent; background: none; font: inherit; cursor: pointer; width: 100%; color: inherit; }
.festcal-grid .day:hover { border-color: var(--brand); }
.festcal-grid .day.fest { background: var(--err-soft); }
.festcal-grid .day.today { font-weight: 700; box-shadow: inset 0 0 0 1px var(--muted); border-radius: 4px; }
.festcal-legend { display: flex; gap: 1rem; flex-wrap: wrap; margin: .5rem 0 0; }
.festcal-legend span { display: inline-flex; align-items: center; gap: .35rem; }
.festcal-legend i { display: inline-block; width: .8rem; height: .8rem; border-radius: 3px; font-style: normal; }
.festcal-raw { margin-top: .6rem; }
.festcal-raw textarea { margin-top: .35rem; }

/* Acceso */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 1rem; }
.loginbox { width: 100%; max-width: 400px; text-align: center; padding: 2rem 1.6rem; }
.loginbox form { text-align: left; margin-top: 1rem; }

/* Responsive */
@media (max-width: 1000px) {
  .grid2, .grid2.wide-left { grid-template-columns: 1fr; }
  .ra-grid { grid-template-columns: 1fr 1fr; }
  .ra-desc { grid-column: 1 / -1; }
}
@media (max-width: 760px) {
  .navtoggle { display: inline-block; }
  .shell { grid-template-columns: 1fr; }
  .sidebar { display: none; position: fixed; top: 54px; left: 0; right: 0; bottom: 0; height: auto; z-index: 30; border-right: 0; }
  .sidebar.open { display: block; }
  .main { padding: 1rem 16px 3rem; }
  .brand small, .user { display: none; }
  .topbar { gap: .5rem; padding: .5rem 12px; }
  .filters { width: 100%; }
  .filters label { width: 100%; }
  .filters select, .pagehead form select { flex: 1; min-width: 0; max-width: none; }
  .pagehead > form, .pagehead .inline { width: 100%; }
  .pagehead .actions { width: 100%; }
  .pagehead .actions form.inline, .pagehead > form.inline { display: flex; width: 100%; }
  .pagehead .actions form.inline select { flex: 1; min-width: 0; width: 100%; }
  .ces-table td:first-child { word-break: break-word; }
  .curso-sel select { max-width: 130px; }
  .tablefilter { min-width: 0; width: 100%; }
  .g-row { grid-template-columns: 150px minmax(520px, 1fr); }
  .dl { grid-template-columns: 1fr; } .dl dt { margin-top: .3rem; }
}
@media print {
  .topbar, .sidebar, .actions, .formactions, .toolbar, .filters, .btn, .navtoggle { display: none !important; }
  .shell { display: block; } .main { padding: 0; } .card { box-shadow: none; break-inside: avoid; }
  body { background: #fff; color: #000; }
}

/* Anexos oficiales */
details.anexo { padding: 0; }
details.anexo > summary { cursor: pointer; padding: .8rem 1rem; display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; list-style: none; }
details.anexo > summary::-webkit-details-marker { display: none; }
details.anexo > summary::before { content: '▸'; color: var(--muted); }
details.anexo[open] > summary::before { content: '▾'; }
details.anexo[open] > summary { border-bottom: 1px solid var(--line); }
details.anexo > :not(summary) { margin-left: 1rem; margin-right: 1rem; }
details.anexo > form, details.anexo > .tablewrap:last-child, details.anexo > p:last-child { margin-bottom: 1rem; }
.anexo-cod { font-weight: 700; min-width: 6.5em; } .anexo-tit { flex: 1 1 18em; }
details.anexo > table.kvt { width: calc(100% - 2rem); }
.kvt th { width: 8em; color: var(--muted); font-weight: 600; vertical-align: top; }
details.anexo h3 { font-size: .95rem; margin: 1rem 0 .4rem; }

/* Alumnado: acciones masivas, tarjetas de resumen enlazables, lista de requisitos */
a.kpi { color: inherit; text-decoration: none; }
a.kpi:hover { border-color: var(--brand); }
.bulk:not([hidden]) { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; position: sticky; top: 62px; z-index: 5; padding: .6rem .9rem; }
.bulk label:not([hidden]) { display: inline-flex; align-items: center; gap: .35rem; font-size: .9rem; }
.checklist { list-style: none; margin: 0 0 .6rem; padding: 0; display: grid; gap: .45rem; }
.checklist li { display: flex; gap: .5rem; align-items: baseline; }
a.kpi { color: inherit; text-decoration: none; display: block; }
a.kpi:hover { border-color: var(--accent, #2b6cb0); }

/* Barra de formato de texto (negrita, cursiva, listas) */
.rich-bar { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 2px 0 4px; }
.rich-bar button { padding: 2px 9px; font-size: .85rem; border: 1px solid var(--line); background: var(--panel); color: inherit; border-radius: 6px; cursor: pointer; }
.rich-bar button:hover { background: var(--soft); }

/* Cuadro de mando (v1.22): paneles de anexos, requisitos, horas y convenios */
.cardhead { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: .3rem .8rem; margin-bottom: .5rem; }
.cardhead h2 { margin: 0; }
.subhead { font-size: .78rem; font-weight: 600; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); margin: .9rem 0 .35rem; }
details > summary.subhead { margin: 0 0 .35rem; }
.stack { display: flex; gap: 2px; height: 12px; border-radius: 99px; overflow: hidden; background: var(--soft); margin: .35rem 0 .5rem; }
.stack > span { display: block; min-width: 4px; }
.seg-ok { background: var(--ok); } .seg-warn { background: var(--warn); } .seg-err { background: var(--err); }
.seg-info { background: var(--info); } .seg-muted { background: var(--muted); } .seg-brand { background: var(--brand); }
.legend { display: flex; flex-wrap: wrap; gap: .25rem .9rem; font-size: .84rem; margin-bottom: .5rem; }
.legend a { color: inherit; text-decoration: none; } .legend a:hover b { text-decoration: underline; }
.dot { display: inline-block; width: .6rem; height: .6rem; border-radius: 50%; margin-right: .3rem; }
.chips { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem .5rem; margin: -.3rem 0 .9rem; }
.chip { display: inline-flex; align-items: center; gap: .35rem; background: var(--brand-soft); color: var(--ink); border-radius: 99px; padding: .1rem .35rem .1rem .7rem; font-size: .82rem; }
.chip a { color: var(--muted); text-decoration: none; font-weight: 700; padding: 0 .35rem; border-radius: 99px; } .chip a:hover { color: var(--err); }
.mini-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: .5rem; margin-bottom: .7rem; }
.mini { display: block; background: var(--soft); border-radius: 8px; border-left: 3px solid transparent; padding: .4rem .6rem; color: inherit; text-decoration: none; }
.mini b { display: block; font-size: 1.2rem; line-height: 1.25; font-variant-numeric: tabular-nums; }
.mini span { font-size: .78rem; color: var(--muted); line-height: 1.25; display: block; }
.mini.good { border-left-color: var(--ok); } .mini.warn { border-left-color: var(--warn); } .mini.bad { border-left-color: var(--err); }
a.mini:hover { outline: 1px solid var(--brand); }
.matrix th.c, .matrix td.c { text-align: center; }
.card .bar i { background: var(--ink); }

/* v1.28 · usabilidad */
.navtitle[role="button"] { cursor: pointer; display: flex; justify-content: space-between; align-items: center; user-select: none; }
.navtitle[role="button"]::after { content: "▾"; font-size: .8rem; transition: transform .15s; }
.navgroup.collapsed .navtitle::after { transform: rotate(-90deg); }
.navgroup.collapsed > a { display: none; }
kbd { font: inherit; font-size: .72rem; border: 1px solid var(--line); border-radius: 4px; padding: 0 .3em; color: var(--muted); }
.palette { position: fixed; inset: 0; background: rgba(10, 15, 25, .5); z-index: 60; display: flex; justify-content: center; align-items: flex-start; padding-top: 12vh; }
.palette[hidden] { display: none; }
.palette-box { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); width: min(640px, 92vw); padding: .8rem; box-shadow: 0 12px 40px rgba(0, 0, 0, .35); }
.palette-input { width: 100%; font-size: 1.05rem; padding: .6rem .8rem; }
.palette-list { list-style: none; margin: .5rem 0 0; padding: 0; max-height: 50vh; overflow-y: auto; }
.palette-list li a { display: flex; justify-content: space-between; gap: 1rem; padding: .45rem .7rem; border-radius: 6px; text-decoration: none; color: var(--ink); }
.palette-list li a small { color: var(--muted); }
.palette-list li.sel a, .palette-list li a:hover { background: var(--brand-soft); }
.palette-list li.empty { padding: .6rem .7rem; color: var(--muted); }
.palette-help { margin: .5rem .2rem 0; }
th.sortable { cursor: pointer; user-select: none; }
th.sortable::after { content: " ↕"; opacity: .35; font-size: .8em; }
th.sortable[aria-sort="ascending"]::after { content: " ↑"; opacity: 1; }
th.sortable[aria-sort="descending"]::after { content: " ↓"; opacity: 1; }
.sticky-form { position: sticky; bottom: 0; background: var(--panel); padding: .6rem 0; border-top: 1px solid var(--line); z-index: 4; }
.dangerzone { display: flex; justify-content: space-between; align-items: center; gap: 1rem; border-color: var(--err); margin-top: 1rem; }
.dangerzone p { margin: .1rem 0 0; }
.flash { position: relative; padding-right: 2.2rem; transition: opacity .4s; }
.flash.fade { opacity: 0; }
.flash-x { position: absolute; right: .5rem; top: .35rem; background: none; border: 0; font-size: 1.2rem; line-height: 1; cursor: pointer; color: inherit; }
button.busy { opacity: .6; cursor: progress; }
.toast { position: fixed; right: 1rem; bottom: 1rem; background: var(--ink); color: var(--bg); padding: .6rem .9rem; border-radius: 8px; box-shadow: var(--shadow); opacity: 0; transform: translateY(8px); transition: all .25s; pointer-events: none; z-index: 70; max-width: 80vw; }
.toast.on { opacity: 1; transform: none; }
.pendiente { border-left: 4px solid var(--brand); margin-bottom: 1rem; }
.pendlist { list-style: none; margin: 0; padding: 0; display: grid; gap: .35rem; }
.pendlist li a { display: block; padding: .45rem .7rem; border-radius: 6px; text-decoration: none; color: var(--ink); background: var(--soft); }
.pendlist li.err a { background: var(--err-soft); color: var(--err); }
.pendlist li.warn a { background: var(--warn-soft); color: var(--warn); }
.pendlist li a:hover { filter: brightness(.96); }
@media print { .palette, .toast, .flash-x { display: none !important; } }

/* v1.29 · permisos por rol */
.tabs { display: flex; flex-wrap: wrap; gap: .3rem; margin-bottom: 1rem; border-bottom: 1px solid var(--line); }
.tab { padding: .45rem .8rem; border-radius: 8px 8px 0 0; text-decoration: none; color: var(--ink); border: 1px solid transparent; border-bottom: 0; }
.tab:hover { background: var(--soft); }
.tab.active { background: var(--panel); border-color: var(--line); color: var(--brand); font-weight: 600; margin-bottom: -1px; }
.badge.warn { background: var(--warn-soft); color: var(--warn); font-size: .7rem; padding: 0 .45em; border-radius: 99px; margin-left: .3rem; }

/* v1.39 · lienzo para firmar con tableta */
.firma-pad { margin: .5rem 0 1rem; }
.firma-pad-canvas { display: block; width: 100%; max-width: 600px; aspect-ratio: 3 / 1; background: #fff; border: 1px dashed var(--line); border-radius: 6px; touch-action: none; cursor: crosshair; }
.firma-pad-barra { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; margin-top: .4rem; }

/* v1.40 · firma en pantalla: documento mostrado y selector */
.firma-tabs { display: flex; gap: .4rem; flex-wrap: wrap; margin: .5rem 0; }
.docvista { background: #fff; color: #111; border: 1px solid var(--line); border-radius: 6px; padding: 1.2rem 1.5rem; max-height: 65vh; overflow: auto; font-size: .92rem; }
.docvista p { margin: 0 0 .45rem; white-space: pre-wrap; }
.docvista table { border-collapse: collapse; width: 100%; margin: .5rem 0; }
.docvista td { border: 1px solid #bbb; padding: .25rem .4rem; vertical-align: top; }
.pdfvista { width: 100%; height: 70vh; border: 1px solid var(--line); border-radius: 6px; background: #fff; }

/* ==========================================================================
   v1.45.1 · mejoras de aspecto (solo CSS: no cambia ninguna funcionalidad)
   ========================================================================== */
:root {
  --radius: 12px;
  --shadow: 0 1px 2px rgba(20, 30, 50, .05), 0 4px 14px rgba(20, 30, 50, .05);
  --shadow-hover: 0 2px 4px rgba(20, 30, 50, .07), 0 8px 22px rgba(20, 30, 50, .09);
  --ring: 0 0 0 3px color-mix(in srgb, var(--brand) 24%, transparent);
  --line-strong: color-mix(in srgb, var(--line) 70%, var(--muted));
}
html { scroll-behavior: smooth; }
body { -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; text-rendering: optimizeLegibility; }
::selection { background: var(--brand-soft); color: var(--ink); }
h1 { font-size: 1.6rem; letter-spacing: -.015em; }
h2 { letter-spacing: -.005em; }

/* Barra superior */
.topbar { box-shadow: 0 1px 0 var(--line), 0 3px 14px rgba(20, 30, 50, .05); backdrop-filter: saturate(1.4) blur(6px); }
.brand { gap: .55rem; align-items: center; }
.brand.big { align-items: center; gap: .8rem; }
.logo-mark { box-shadow: 0 1px 2px rgba(0, 0, 0, .18), inset 0 1px 0 rgba(255, 255, 255, .22); }
.user { padding: .1rem .5rem; border-radius: 8px; transition: background .15s; }
.user:hover { background: var(--soft); }
.curso-sel select { border-radius: 8px; }
@media (max-width: 1100px) { .brand small { display: none; } }

/* Menú lateral */
.sidebar {
  background: linear-gradient(180deg, var(--sb-bg) 0%, color-mix(in srgb, var(--sb-bg) 88%, #000) 100%);
  box-shadow: inset -1px 0 0 rgba(0, 0, 0, .08);
  scrollbar-width: thin; scrollbar-color: rgba(255, 255, 255, .35) transparent;
}
.navgroup { margin-bottom: .55rem; }
.navtitle { font-weight: 700; letter-spacing: .08em; padding: .45rem .6rem .25rem; }
.sidebar a { position: relative; transition: background .12s, padding-left .12s; margin-bottom: 1px; }
.sidebar a:hover:not(.active) { padding-left: .8rem; }
.sidebar a.active { box-shadow: 0 1px 3px rgba(0, 0, 0, .22); }
.navfoot { opacity: .8; }

/* Cabecera de página y bloques */
.pagehead { padding-bottom: .85rem; border-bottom: 1px solid var(--line); margin-bottom: 1.2rem; align-items: center; }
.pagehead > div > p.intro, .pagehead .intro { margin-bottom: 0; }
.card { border-radius: var(--radius); transition: box-shadow .15s, border-color .15s; }
.card > h2:first-child, .card > .cardhead:first-child { padding-bottom: .1rem; }
.linkcard { transition: box-shadow .15s, border-color .15s, transform .15s; }
.linkcard:hover { box-shadow: var(--shadow-hover); transform: translateY(-1px); }
.tablewrap + .card, .table + .card, .tablewrap + form.card { margin-top: 1.1rem; }

/* Indicadores */
.kpi { position: relative; overflow: hidden; transition: box-shadow .15s, border-color .15s, transform .15s; display: flex; flex-direction: column; justify-content: center; }
a.kpi:hover, a.mini:hover { box-shadow: var(--shadow-hover); transform: translateY(-1px); }
.kpi .kv { letter-spacing: -.02em; }
.kpi .kl { margin-top: .1rem; }
.mini { transition: background .12s; }

/* Botones y formularios */
.btn { transition: filter .12s, background .12s, box-shadow .12s, transform .05s; box-shadow: 0 1px 2px rgba(0, 0, 0, .12); }
.btn:hover { filter: brightness(1.07); box-shadow: 0 2px 6px rgba(0, 0, 0, .16); }
.btn:active { transform: translateY(1px); box-shadow: none; }
.btn.ghost, .btn.danger { box-shadow: none; background: var(--panel); }
.btn.ghost:hover { background: var(--soft); box-shadow: none; filter: none; border-color: var(--line-strong); }
.btn.danger:hover { filter: none; box-shadow: none; }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--brand) 55%, transparent); outline-offset: 2px; border-radius: 6px; }
input, select, textarea { transition: border-color .12s, box-shadow .12s; }
input:hover:not(:focus):not([readonly]), select:hover:not(:focus), textarea:hover:not(:focus) { border-color: var(--line-strong); }
input:focus, select:focus, textarea:focus { box-shadow: var(--ring); }
input[type=checkbox], input[type=radio] { accent-color: var(--brand); }
.field label, .inlineform label { color: var(--ink); }
.formsection { font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; font-weight: 700; }
.filters, .toolbar:has(select) {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: .55rem .8rem; gap: .5rem .9rem; box-shadow: var(--shadow);
}
.filters label { color: var(--ink); font-weight: 600; }
.filters select, .filters input { font-weight: 400; }
.tabs { gap: .2rem; }
.tab { transition: background .12s, color .12s; }

/* Tablas: las que están sueltas sobre el fondo pasan a tener su propia tarjeta */
.tablewrap:not(.card .tablewrap) { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 1rem; }
.table th, .table td { padding: .6rem .7rem; }
.table thead th { border-bottom: 1px solid var(--line-strong); font-weight: 700; letter-spacing: .04em; white-space: nowrap; }
.table tbody tr { transition: background .1s; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: color-mix(in srgb, var(--brand-soft) 45%, transparent); }
.table td a:not(.btn) { text-decoration: none; font-weight: 600; }
.table td a:not(.btn):hover { text-decoration: underline; }
.table td a[href^="mailto:"] { font-weight: 400; overflow-wrap: anywhere; }
.table .btn.sm { white-space: nowrap; }
.table td.right, .table th.right { font-variant-numeric: tabular-nums; }
.table tfoot th, .table tfoot td { border-top: 1px solid var(--line-strong); }

/* Etiquetas, avisos y alertas */
.badge { padding: .1rem .55rem; letter-spacing: .01em; }
.flash { border-left-width: 4px; border-left-color: currentColor; box-shadow: var(--shadow); }
.alert { border-left: 3px solid transparent; }
.alert.error { border-left-color: var(--err); } .alert.aviso { border-left-color: var(--warn); } .alert.info, .alert.ok { border-left-color: var(--line-strong); }
.pendiente { border-radius: var(--radius); }
.pendlist li a { transition: filter .12s, transform .12s; }
.pendlist li a:hover { transform: translateX(2px); }

/* Barras de progreso */
.bar, .hbar { background: color-mix(in srgb, var(--soft) 85%, var(--line)); }
.bar span, .hbar span { transition: width .3s ease; }

/* Acceso */
.auth { background: radial-gradient(1200px 500px at 50% -10%, var(--brand-soft), transparent 70%), var(--bg); }
.loginbox { box-shadow: 0 10px 40px rgba(20, 30, 50, .12), 0 2px 6px rgba(20, 30, 50, .06); border-radius: 16px; padding: 2.4rem 2rem 2rem; }
.loginbox .brand.big { margin-bottom: .3rem; }
.loginbox input:not([type=checkbox]) { padding: .6rem .7rem; }
.loginbox .btn.block { margin-top: .3rem; }

/* Ventanas emergentes y atajos */
.popform, .palette-box { border-radius: var(--radius); }
.toast { border-radius: 10px; }
kbd { background: var(--soft); box-shadow: 0 1px 0 var(--line); }

/* Modo oscuro: matices propios */
@media (prefers-color-scheme: dark) {
  .topbar { box-shadow: 0 1px 0 var(--line); }
  .sidebar { box-shadow: none; scrollbar-color: rgba(0, 0, 0, .35) transparent; }
  .sidebar a.active { box-shadow: none; }
  .table tbody tr:hover { background: color-mix(in srgb, var(--soft) 80%, transparent); }
  .auth { background: radial-gradient(1200px 500px at 50% -10%, color-mix(in srgb, var(--brand-soft) 70%, transparent), transparent 70%), var(--bg); }
  .loginbox { box-shadow: 0 10px 40px rgba(0, 0, 0, .45); }
}

/* Pantallas pequeñas */
@media (max-width: 760px) {
  h1 { font-size: 1.35rem; }
  .filters, .toolbar:has(select) { padding: .5rem .6rem; }
  .table th, .table td { padding: .5rem .5rem; }
  .loginbox { padding: 1.8rem 1.2rem 1.5rem; }
}

/* Respeta a quien reduce el movimiento en el sistema */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}
/* Impresión: sin efectos añadidos */
@media print {
  .tablewrap:not(.card .tablewrap) { border: 0; box-shadow: none; }
  .card, .kpi, .btn { box-shadow: none !important; }
}
.brand.big .logo-mark { width: 1.9em; height: 1.9em; font-size: 1.15em; border-radius: 10px; }

/* Tablas con clase «grid» (Calendario y Gantt): mismo aspecto que .table */
table.grid { width: 100%; border-collapse: collapse; font-size: .9rem; }
table.grid th, table.grid td { padding: .55rem .7rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
table.grid thead th { font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; font-weight: 700; color: var(--muted); background: var(--soft); border-bottom: 1px solid var(--line-strong); white-space: nowrap; }
table.grid tbody tr:last-child td { border-bottom: 0; }
table.grid tbody tr:hover { background: color-mix(in srgb, var(--brand-soft) 45%, transparent); }
.card:has(> table.grid) { padding: 0; overflow: hidden; }

/* Móvil: el botón de búsqueda no se parte en varias líneas */
[data-search] { white-space: nowrap; }
@media (max-width: 760px) { [data-search] kbd { display: none; } }
