/* QUAADRIL · estilos base. Mobile-first, sin dependencias externas. */
:root {
  --accent: #4FB5A3;
  --accent-hover: #72C9B9;
  --radius: 14px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
[data-theme="dark"] {
  --bg: #060c0b; --surface: #0f1a18; --surface-2: #162522; --border: #23383400;
  --line: #24403a; --text: #e8f1ef; --muted: #9bb3ad; --on-accent: #04110e;
  --danger-bg: #3a1414; --danger: #ffb4b4;
}
[data-theme="light"] {
  --bg: #f6faf9; --surface: #ffffff; --surface-2: #eef5f3; --line: #cfe1dc;
  --text: #0b1a17; --muted: #4c625d; --on-accent: #04110e;
  --accent: #2f8f7e; --accent-hover: #3aa391;  /* más oscuro para contraste AA sobre blanco */
  --danger-bg: #fde8e8; --danger: #8a1c1c;
}
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--font); background: var(--bg); color: var(--text); line-height: 1.5; font-size: 1rem; }
a { color: var(--accent); }
a:hover { color: var(--accent-hover); }
h1, h2 { line-height: 1.2; margin: 0 0 .5rem; }
h1 { font-size: 1.6rem; } h2 { font-size: 1.1rem; }

.topbar { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; padding: .6rem 1rem; background: var(--surface); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: .5rem; font-weight: 700; letter-spacing: .04em; color: var(--text); text-decoration: none; }
.brand small { font-weight: 400; color: var(--muted); letter-spacing: 0; }
.brand-mark { display: inline-grid; place-items: center; width: 1.8rem; height: 1.8rem; border-radius: 8px; background: var(--accent); color: var(--on-accent); }
.topbar-actions { display: flex; align-items: center; gap: .5rem; }
.topbar-actions form { margin: 0; }
.icon-btn, .link-btn { background: none; border: 1px solid var(--line); color: var(--text); border-radius: 999px;
  padding: .35rem .8rem; font: inherit; cursor: pointer; min-height: 2.25rem; }
.icon-btn:hover, .link-btn:hover { border-color: var(--accent); }

.container { max-width: 960px; margin: 0 auto; padding: 1rem; }
.footer { color: var(--muted); font-size: .8rem; text-align: center; padding: 2rem 1rem; }
.muted { color: var(--muted); } .small { font-size: .85rem; } .center { text-align: center; }
.eyebrow { color: var(--accent); font-size: .85rem; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; margin: 0 0 .25rem; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.25rem; margin: 1rem 0; }
.narrow { max-width: 420px; margin-left: auto; margin-right: auto; }
.hero { padding: 1rem 0 .5rem; }
.stack { display: flex; flex-direction: column; gap: .6rem; }

.grid { display: grid; grid-template-columns: 1fr; gap: .75rem; margin: 1rem 0; }
@media (min-width: 560px) { .grid { grid-template-columns: 1fr 1fr; } }
@media (min-width: 860px) { .grid { grid-template-columns: 1fr 1fr 1fr; } }
.tile { display: block; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1rem; color: var(--text); text-decoration: none; }
.tile p { margin: 0; color: var(--muted); font-size: .9rem; }
a.tile[href]:hover { border-color: var(--accent); }
.tile.is-pending { opacity: .55; }

label { font-weight: 600; font-size: .9rem; }
input, select, textarea { font: inherit; color: var(--text); background: var(--surface-2); border: 1px solid var(--line);
  border-radius: 10px; padding: .7rem .8rem; width: 100%; }
input:focus, select:focus, textarea:focus, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.code-input { font-size: 1.4rem; letter-spacing: .2em; text-transform: uppercase; text-align: center; font-family: ui-monospace, monospace; }
.btn { background: var(--accent); color: var(--on-accent); border: 0; border-radius: 10px; padding: .8rem 1rem;
  font: inherit; font-weight: 700; cursor: pointer; min-height: 2.75rem; text-decoration: none; display: inline-block; }
.btn:hover { background: var(--accent-hover); color: var(--on-accent); }

.alert { background: var(--danger-bg); color: var(--danger); border-radius: 10px; padding: .7rem .9rem; margin: .5rem 0; }
.messages { list-style: none; padding: 0; margin: 0; }
.msg { background: var(--surface-2); border-left: 4px solid var(--accent); border-radius: 8px; padding: .6rem .8rem; margin-bottom: .5rem; }

.qr { background: #fff; padding: 8px; border-radius: 10px; max-width: 100%; height: auto; }
.code-display { font-family: ui-monospace, monospace; font-size: 1.5rem; letter-spacing: .25em; margin: .5rem 0 0; }

/* ── Gestión ─────────────────────────────────────────────────────────── */
.subnav { display: flex; flex-wrap: wrap; gap: .4rem; margin: 0 0 1rem; }
.subnav a { border: 1px solid var(--line); border-radius: 999px; padding: .3rem .8rem; text-decoration: none; color: var(--text); font-size: .9rem; }
.subnav a:hover { border-color: var(--accent); }
.chip { display: inline-block; border: 1px solid var(--line); border-radius: 999px; padding: .25rem .7rem; margin: 0 .3rem .4rem 0;
  color: var(--text); text-decoration: none; font-size: .9rem; }
.chip-warn { border-color: #d9a441; }
.filters { display: flex; align-items: center; gap: .5rem; margin: .5rem 0 1rem; }
.filters select { width: auto; }
.btn-small { padding: .45rem .8rem; min-height: 0; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); }
.table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.table th, .table td { text-align: left; padding: .55rem .7rem; border-bottom: 1px solid var(--line); vertical-align: top; }
.table th { background: var(--surface-2); font-weight: 600; white-space: nowrap; }
.table tr:last-child td { border-bottom: 0; }
.table select { width: auto; padding: .3rem .5rem; }
.table tr.inactive { opacity: .5; }
.mono { font-family: ui-monospace, monospace; letter-spacing: .08em; }
.ok-flash { color: var(--accent); font-size: .85rem; margin-left: .3rem; }
.row-actions { display: flex; gap: .75rem; align-items: center; margin-top: 1rem; }
.errors { color: var(--danger); padding-left: 1.2rem; }
code { background: var(--surface-2); border-radius: 4px; padding: 0 .3rem; font-size: .9em; }

/* ── Programa ────────────────────────────────────────────────────────── */
.now-next { display: grid; gap: .6rem; margin: 1rem 0; }
@media (min-width: 640px) { .now-next { grid-template-columns: 1fr 1fr; } }
.nn-card { display: flex; flex-direction: column; gap: .15rem; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: .9rem 1rem; color: var(--text); text-decoration: none; }
.nn-now { border-color: var(--accent); box-shadow: inset 4px 0 0 var(--accent); }
.nn-label { font-size: .8rem; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--accent); }
.nn-title { font-weight: 600; }
.nn-meta { color: var(--muted); font-size: .9rem; }
.day-tabs { display: flex; gap: .3rem; overflow-x: auto; margin: 1rem 0 .5rem; padding-bottom: .2rem; }
.day-tabs a { flex: none; border: 1px solid var(--line); border-radius: 999px; padding: .35rem .9rem; text-decoration: none; color: var(--text); text-transform: capitalize; }
.day-tabs a.active { background: var(--accent); color: var(--on-accent); border-color: var(--accent); font-weight: 700; }
.day-title { margin-top: 1rem; }
.day-title::first-letter { text-transform: uppercase; }
.agenda { list-style: none; padding: 0; margin: .5rem 0 1rem; }
.ag-item { display: grid; grid-template-columns: 3.6rem 1fr auto; gap: .75rem; padding: .7rem .4rem; border-bottom: 1px solid var(--line); }
.ag-item.is-now { background: var(--surface-2); border-radius: 10px; box-shadow: inset 4px 0 0 var(--accent); }
.ag-break, .ag-lunch { padding-top: .35rem; padding-bottom: .35rem; font-size: .9rem; }
.ag-time { font-variant-numeric: tabular-nums; font-weight: 600; display: flex; flex-direction: column; line-height: 1.2; }
.ag-time small { color: var(--muted); font-weight: 400; }
.ag-body { display: flex; flex-direction: column; gap: .15rem; min-width: 0; }
.ag-title { font-weight: 600; color: var(--text); text-decoration: none; }
a.ag-title:hover { color: var(--accent); }
.ag-meta { color: var(--muted); font-size: .9rem; }
.ag-desc { color: var(--muted); font-size: .85rem; margin: .2rem 0 0; }
.ag-edit { color: var(--muted); text-decoration: none; padding: 0 .3rem; }
.badge { align-self: flex-start; font-size: .75rem; background: var(--surface-2); border: 1px solid var(--line); border-radius: 999px; padding: 0 .5rem; color: var(--accent); }
.file-list { list-style: none; padding: 0; }
.file-list li { display: flex; flex-wrap: wrap; align-items: baseline; gap: .5rem; padding: .5rem 0; border-bottom: 1px solid var(--line); }
form.inline { display: inline; margin: 0; }
.link-btn.danger, .danger { color: var(--danger); }
.mat-group { margin: 1.25rem 0; }
.prose p { margin: 0 0 .6rem; }
.tile-admin { border-style: dashed; }
details.card summary { cursor: pointer; font-weight: 600; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: .6rem; margin: 1rem 0; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: .8rem; display: flex; flex-direction: column; }
.stat b { font-size: 1.6rem; } .stat span { color: var(--muted); font-size: .85rem; }
.stat-warn { border-color: #d9a441; }
.errorlist { color: var(--danger); list-style: none; padding: 0; margin: 0; font-size: .9rem; }

/* ── Criterios ───────────────────────────────────────────────────────── */
.search { display: flex; flex-wrap: wrap; gap: .5rem; margin: 1rem 0; }
.search input { flex: 1 1 240px; } .search select { flex: 0 1 220px; width: auto; }
.form-code { font-family: ui-monospace, monospace; color: var(--accent); font-size: .85em; margin-right: .3rem; }
.sec-tree { list-style: none; padding: 0; margin: .5rem 0 0; }
.sec-tree li { padding: .35rem 0; border-bottom: 1px solid var(--line); display: flex; gap: .5rem; align-items: baseline; }
.sec-tree li:last-child { border-bottom: 0; }
.sec-tree li.depth-0 { font-weight: 600; }
.sec-tree li.depth-1 { padding-left: 1.2rem; }
.sec-tree a { color: var(--text); text-decoration: none; flex: 1; }
.sec-tree a:hover { color: var(--accent); }
.sec-tree .mono { color: var(--muted); font-size: .85em; margin-right: .3rem; }
.crumbs { font-size: .85rem; color: var(--muted); margin-bottom: .5rem; }
.note { background: #3a2c0e; color: #ffd98a; border-radius: 8px; padding: .45rem .7rem; font-size: .9rem; }
[data-theme="light"] .note { background: #fff4d6; color: #6b4a00; }
.crit-list { list-style: none; padding: 0; margin: .5rem 0; }
.crit { border-bottom: 1px solid var(--line); padding: .7rem 0; scroll-margin-top: 4rem; }
.crit:target { background: var(--surface-2); border-radius: 8px; }
.crit-head { display: grid; grid-template-columns: 2rem 1fr auto; gap: .5rem; align-items: start; }
.crit-num { font-family: ui-monospace, monospace; color: var(--muted); padding-top: .1rem; }
.crit-text { margin: 0; }
.crit-more { margin: .35rem 0 0 2.5rem; font-size: .92rem; }
.crit-more summary { color: var(--accent); cursor: pointer; font-size: .85rem; }
.crit-list.compact .crit { padding: .4rem 0; }
.subgroup { font-weight: 600; padding-top: .6rem; color: var(--accent); }
.mchip { display: inline-block; font-size: .72rem; font-weight: 600; border-radius: 999px; padding: .05rem .5rem; white-space: nowrap; border: 1px solid; }
.m-documental { color: #8fc1ff; border-color: #2c4a70; }
.m-entrevista { color: #f0b3ff; border-color: #5c2f6b; }
.m-instalaciones { color: #ffc98a; border-color: #6b4a1c; }
[data-theme="light"] .m-documental { color: #1d4f91; border-color: #9bbbe6; }
[data-theme="light"] .m-entrevista { color: #7a2a8f; border-color: #d6a6e3; }
[data-theme="light"] .m-instalaciones { color: #8a4b00; border-color: #e6b77a; }
.inline-h { display: inline; font-size: 1.05rem; }
details > summary { cursor: pointer; }
.actions { padding-left: 0; list-style: none; }
.actions > li { padding: .45rem 0; border-bottom: 1px solid var(--line); }
.act-label { font-family: ui-monospace, monospace; color: var(--accent); }
.pager { display: flex; justify-content: space-between; margin: 1.5rem 0; }
.crit-results { list-style: none; padding: 0; }
.crit-results li { padding: .4rem 0; border-bottom: 1px solid var(--line); }
.crit-results a { color: var(--text); text-decoration: none; }
.glossary { display: grid; grid-template-columns: max-content 1fr; gap: .3rem 1rem; }
.glossary dt { font-weight: 700; } .glossary dd { margin: 0; color: var(--muted); }
.chips { display: flex; flex-wrap: wrap; }
.scale { margin-top: -.3rem; }
