/* ==========================================================================
   Estilos base del Sistema de Matrículas CEDER
   Orden: reset · layout · barra lateral · barra superior · componentes · responsive
   ========================================================================== */

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: var(--fs-md);
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
}
h1, h2, h3, p { margin: 0; }
a { color: var(--brand-600); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font: inherit; cursor: pointer; }
[hidden] { display: none !important; }

:focus-visible { outline: 2px solid var(--brand-600); outline-offset: 2px; }

.icon {
  width: 20px; height: 20px; flex: none;
  fill: none; stroke: currentColor; stroke-width: 1.75;
  stroke-linecap: round; stroke-linejoin: round;
}
.icon--sm { width: 16px; height: 16px; }
.muted { color: var(--text-muted); }

.skip-link {
  position: absolute; left: -999px; top: var(--sp-2);
  background: var(--surface); padding: var(--sp-2) var(--sp-3); z-index: 100;
}
.skip-link:focus { left: var(--sp-2); }

/* ---------- Layout ---------- */
.app-main { margin-left: var(--sidebar-w); min-height: 100vh; display: flex; flex-direction: column; }
.content { padding: var(--sp-6); max-width: 1400px; width: 100%; }
.content:focus { outline: none; }

.page-header {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: var(--sp-4); margin-bottom: var(--sp-5); flex-wrap: wrap;
}
.page-title { font-size: var(--fs-xl); font-weight: 600; letter-spacing: -.01em; }
.page-subtitle { color: var(--text-muted); margin-top: var(--sp-1); }
.page-actions { display: flex; gap: var(--sp-2); }
.breadcrumb { font-size: var(--fs-sm); color: var(--text-muted); margin-bottom: var(--sp-1); }

/* ---------- Barra lateral ---------- */
.sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--sidebar-w);
  background: var(--surface); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; z-index: 40;
}
.sidebar__brand {
  height: var(--topbar-h); display: flex; align-items: center; gap: var(--sp-3);
  padding: 0 var(--sp-5); border-bottom: 1px solid var(--border);
}
.brand-mark { width: 40px; height: 40px; flex: none; object-fit: contain; }
.brand-text { display: flex; flex-direction: column; line-height: 1.2; }
.brand-text strong { font-size: var(--fs-md); letter-spacing: .02em; }
.brand-text small { font-size: var(--fs-xs); color: var(--text-muted); }
.sidebar .sidebar__close { display: none; margin-left: auto; }

.sidebar__nav { flex: 1; overflow-y: auto; padding: var(--sp-4) var(--sp-3); }
.nav-section {
  font-size: var(--fs-xs); font-weight: 600; text-transform: uppercase; letter-spacing: .06em;
  color: var(--text-soft); padding: var(--sp-3) var(--sp-3) var(--sp-2);
}
.nav-list { list-style: none; margin: 0 0 var(--sp-2); padding: 0; }
.nav-link {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: var(--sp-2) var(--sp-3); border-radius: var(--radius-sm);
  color: var(--text-muted); font-size: var(--fs-sm); font-weight: 500;
}
.nav-link:hover { background: var(--bg); color: var(--text); text-decoration: none; }
.nav-link.is-active { background: var(--brand-50); color: var(--brand-700); }
.nav-link.is-active .icon { color: var(--brand-600); }
.nav-badge {
  margin-left: auto; font-size: .6875rem; color: var(--text-soft);
  border: 1px solid var(--border); border-radius: 999px; padding: 0 var(--sp-2);
}
.sidebar__footer {
  padding: var(--sp-4) var(--sp-5); border-top: 1px solid var(--border);
  font-size: var(--fs-xs); color: var(--text-soft);
}
.sidebar-backdrop { position: fixed; inset: 0; background: rgba(16, 24, 40, .4); z-index: 35; }

/* ---------- Barra superior ---------- */
.topbar {
  position: sticky; top: 0; z-index: 30; height: var(--topbar-h);
  display: flex; align-items: center; gap: var(--sp-4);
  padding: 0 var(--sp-6); background: var(--surface); border-bottom: 1px solid var(--border);
}
.topbar .topbar__menu { display: none; }
.topbar__title { display: flex; align-items: center; gap: var(--sp-3); min-width: 0; }
.topbar__system { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.area-chip {
  font-size: var(--fs-xs); font-weight: 500; color: var(--brand-700);
  background: var(--brand-50); border: 1px solid var(--brand-100);
  border-radius: 999px; padding: 2px var(--sp-3); white-space: nowrap;
}

.icon-btn {
  display: inline-grid; place-items: center; width: 38px; height: 38px;
  border: 1px solid transparent; border-radius: var(--radius-sm);
  background: transparent; color: var(--text-muted);
}
.icon-btn:hover { background: var(--bg); color: var(--text); }

.profile { position: relative; margin-left: auto; }
.topbar__avisos { position: relative; margin-left: auto; }
.topbar__avisos + .profile { margin-left: 0; }
.topbar__contador {
  position: absolute; top: 2px; right: 2px; min-width: 18px; height: 18px; padding: 0 4px;
  border-radius: 999px; background: var(--danger); color: #fff; font-size: 11px; line-height: 18px; text-align: center;
}
.notificaciones { list-style: none; margin: 0; padding: 0; }
.notificacion {
  display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4); border-bottom: 1px solid var(--border);
}
.notificacion:last-child { border-bottom: 0; }
.notificacion p { margin: 0; }
.notificacion--nueva .notificacion__mensaje { font-weight: 600; }
.profile__toggle {
  display: flex; align-items: center; gap: var(--sp-3);
  background: none; border: 1px solid transparent; border-radius: var(--radius-sm);
  padding: var(--sp-1) var(--sp-2); color: var(--text-muted);
}
.profile__toggle:hover { background: var(--bg); }
.avatar {
  width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center;
  background: var(--brand-100); color: var(--brand-700); font-weight: 600; font-size: var(--fs-sm);
}
.profile__name { display: flex; flex-direction: column; text-align: left; line-height: 1.2; }
.profile__name strong { font-size: var(--fs-sm); color: var(--text); font-weight: 600; }
.profile__name small { font-size: var(--fs-xs); }

.dropdown {
  position: absolute; right: 0; top: calc(100% + 6px); min-width: 240px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: var(--sp-2);
}
.dropdown__header {
  display: flex; flex-direction: column; padding: var(--sp-2) var(--sp-3) var(--sp-3);
  border-bottom: 1px solid var(--border); margin-bottom: var(--sp-2);
}
.dropdown__header strong { font-size: var(--fs-sm); }
.dropdown__header small { font-size: var(--fs-xs); color: var(--text-muted); }
.dropdown form { margin: 0; }
.dropdown__item {
  display: flex; align-items: center; gap: var(--sp-2); width: 100%;
  padding: var(--sp-2) var(--sp-3); border: 0; background: none; border-radius: var(--radius-sm);
  font-size: var(--fs-sm); color: var(--text); text-align: left;
}
.dropdown__item:hover { background: var(--bg); text-decoration: none; }
.dropdown__item--danger { color: var(--danger); }

/* ---------- Componentes ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-sm); padding: var(--sp-5);
}
.card__header {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--sp-3); margin-bottom: var(--sp-4);
}
.card__title { font-size: var(--fs-md); font-weight: 600; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-2);
  padding: .5625rem var(--sp-4); border-radius: var(--radius-sm);
  font-size: var(--fs-sm); font-weight: 600; border: 1px solid transparent; white-space: nowrap;
}
.btn:hover { text-decoration: none; }
.btn--primary { background: var(--brand-600); color: #fff; }
.btn--primary:hover { background: var(--brand-700); }
.btn--secondary { background: var(--surface); color: var(--text); border-color: var(--border-strong); }
.btn--secondary:hover { background: var(--bg); }
.btn--block { width: 100%; }

.badge {
  font-size: var(--fs-xs); font-weight: 500; color: var(--text-muted);
  background: var(--bg); border: 1px solid var(--border); border-radius: 999px; padding: 1px var(--sp-2);
}

.notice, .alert {
  display: flex; align-items: flex-start; gap: var(--sp-2);
  padding: var(--sp-3) var(--sp-4); border-radius: var(--radius-sm);
  font-size: var(--fs-sm); margin-bottom: var(--sp-5);
}
.notice { background: var(--info-bg); color: var(--info); border: 1px solid var(--brand-100); }
.notice .icon { margin-top: 2px; }
.alert--info { background: var(--info-bg); color: var(--info); }
.alert--success { background: var(--success-bg); color: var(--success); }
.alert--warning { background: var(--warning-bg); color: var(--warning); }
.alert--error { background: var(--danger-bg); color: var(--danger); }

/* Indicadores */
.stats {
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: var(--sp-4); margin-bottom: var(--sp-5);
}
.stat { display: flex; gap: var(--sp-4); align-items: flex-start; }
.stat__icon {
  width: 42px; height: 42px; border-radius: var(--radius-sm); flex: none;
  display: grid; place-items: center; background: var(--brand-50); color: var(--brand-600);
}
.stat__label { font-size: var(--fs-sm); color: var(--text-muted); font-weight: 500; }
.stat__value { font-size: var(--fs-2xl); font-weight: 600; line-height: 1.2; font-variant-numeric: tabular-nums; }
.stat__detail { font-size: var(--fs-xs); color: var(--text-soft); }

.grid-2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); gap: var(--sp-4); }

/* Acciones rápidas */
.quick-actions { display: grid; gap: var(--sp-2); }
.quick-action {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: var(--sp-3); border: 1px solid var(--border); border-radius: var(--radius-sm);
  color: var(--text); font-size: var(--fs-sm); font-weight: 500;
}
.quick-action:hover { border-color: var(--brand-100); background: var(--brand-50); text-decoration: none; }
.quick-action__icon {
  width: 34px; height: 34px; display: grid; place-items: center; flex: none;
  border-radius: var(--radius-sm); background: var(--bg); color: var(--text-muted);
}
.quick-action--primary .quick-action__icon { background: var(--brand-600); color: #fff; }

/* Tablas */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
.table th {
  text-align: left; font-weight: 600; font-size: var(--fs-xs); text-transform: uppercase;
  letter-spacing: .04em; color: var(--text-muted); background: var(--bg);
  padding: var(--sp-2) var(--sp-3); border-bottom: 1px solid var(--border); white-space: nowrap;
}
.table td { padding: var(--sp-3); border-bottom: 1px solid var(--border); }
.table-empty { text-align: center; color: var(--text-muted); font-size: var(--fs-sm); padding: var(--sp-6) var(--sp-4); border-bottom: 1px solid var(--border); }

/* Estado vacío (módulos pendientes) */
.empty-state { text-align: center; padding: var(--sp-6) var(--sp-5); max-width: 560px; margin: 0 auto; }
.empty-state__icon {
  width: 56px; height: 56px; margin: 0 auto var(--sp-4); border-radius: 50%;
  display: grid; place-items: center; background: var(--brand-50); color: var(--brand-600);
}
.empty-state h2 { font-size: var(--fs-lg); font-weight: 600; margin-bottom: var(--sp-2); }
.empty-state p { margin-bottom: var(--sp-2); }
.empty-state .btn { margin-top: var(--sp-4); }

/* Formularios */
.form { display: grid; gap: var(--sp-4); }
.field { display: grid; gap: var(--sp-1); }
.field label { font-size: var(--fs-sm); font-weight: 600; }
.field input, .field select, .field textarea {
  font: inherit; font-size: var(--fs-sm); color: var(--text);
  padding: .625rem var(--sp-3); border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm); background: var(--surface); width: 100%;
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none; border-color: var(--brand-600); box-shadow: 0 0 0 3px var(--brand-100);
}

/* Pantalla de ingreso */
body.auth { min-height: 100vh; display: grid; place-items: center; padding: var(--sp-4); }
.auth-card { width: 100%; max-width: 400px; padding: var(--sp-6); box-shadow: var(--shadow); }
.auth-card__brand { display: flex; align-items: center; gap: var(--sp-3); margin-bottom: var(--sp-6); }
.auth-card__brand div { display: flex; flex-direction: column; line-height: 1.2; }
.auth-card__brand small { font-size: var(--fs-xs); color: var(--text-muted); }
.auth-card__title { font-size: var(--fs-lg); font-weight: 600; }
.auth-card .muted { font-size: var(--fs-sm); margin-bottom: var(--sp-5); }
.auth-card .btn { margin-top: var(--sp-2); padding-block: .6875rem; }
.auth-card__separador { display: flex; align-items: center; gap: var(--sp-3); margin-top: var(--sp-5); font-size: var(--fs-xs); color: var(--text-soft); }
.auth-card__separador::before, .auth-card__separador::after { content: ""; flex: 1; border-top: 1px solid var(--border); }
.auth-card__nota { margin-top: var(--sp-2); font-size: var(--fs-xs); color: var(--text-soft); text-align: center; }
.auth-card__footer { margin-top: var(--sp-6); font-size: var(--fs-xs); color: var(--text-soft); text-align: center; }

/* ---------- Módulo de estudiantes (listados, fichas y formularios por secciones) ---------- */
.content > .card + .card, .content > .card + section, .detail-grid + .card { margin-top: var(--sp-4); }
.card--flush { padding: 0; overflow: hidden; }
.card--flush .table th:first-child, .card--flush .table td:first-child { padding-left: var(--sp-5); }
.card--flush .table th:last-child, .card--flush .table td:last-child { padding-right: var(--sp-5); }
.card--flush .card__nota { margin: 0; padding: var(--sp-3) var(--sp-5); border-top: 1px solid var(--border); }
.firma-vista { max-height: 80px; max-width: 280px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: #fff; }
.texto-legal { max-height: 16rem; overflow-y: auto; padding: var(--sp-3) var(--sp-4); border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--bg); margin-bottom: var(--sp-4); }
.card--sensitive { border-left: 3px solid var(--warning); }
.card__title { display: flex; align-items: center; gap: var(--sp-2); }
.card__title--spaced { margin-top: var(--sp-5); }
.card__actions { display: flex; gap: var(--sp-2); flex-wrap: wrap; }
.card > .card__title + .data { margin-top: var(--sp-3); }

.btn--sm { padding: .375rem var(--sp-3); font-size: var(--fs-xs); }
.btn--ghost { background: transparent; color: var(--text-muted); }
.btn--ghost:hover { background: var(--bg); color: var(--text); }
.badge--success { color: var(--success); background: var(--success-bg); border-color: transparent; }

.small { font-size: var(--fs-sm); }
.t-right { text-align: right; }
.t-nowrap { white-space: nowrap; }
.t-strong { font-weight: 600; color: var(--text); }
.t-mono { font-variant-numeric: tabular-nums; letter-spacing: .01em; }
@media (hover: hover) {
  .table tbody tr:not(:has(.table-vacio)):hover { background: var(--bg); }
}
.table td { vertical-align: middle; }

/* Filtros */
.filters {
  display: grid; grid-template-columns: minmax(240px, 2fr) repeat(3, minmax(170px, 1fr)) auto;
  gap: var(--sp-3); align-items: end; margin-bottom: var(--sp-4);
}
.filters__actions { display: flex; gap: var(--sp-2); }
.input-icon { position: relative; }
.input-icon .icon { position: absolute; left: var(--sp-3); top: 50%; transform: translateY(-50%); color: var(--text-soft); }
.input-icon input { padding-left: 2.25rem; }

/* Paginación */
.pagination {
  display: flex; justify-content: space-between; align-items: center; gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-5); font-size: var(--fs-sm);
}
.pagination div { display: flex; gap: var(--sp-2); }

/* Ficha */
.detail-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--sp-4); }
.data { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--sp-3) var(--sp-4); margin: 0; }
.data dt { font-size: var(--fs-xs); color: var(--text-muted); font-weight: 500; }
.data dd { margin: 0; font-size: var(--fs-sm); }
.data__wide { grid-column: 1 / -1; }

/* Formularios por secciones */
.form-sections { display: grid; gap: var(--sp-4); max-width: 960px; }
.form-section__title { font-size: var(--fs-md); font-weight: 600; margin-bottom: var(--sp-4); }
.field-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--sp-4); }
.field-grid .field, .filters .field { align-content: start; }
.field__help { color: var(--text-muted); font-size: var(--fs-xs); }
.field__error { color: var(--danger); font-size: var(--fs-xs); font-weight: 500; }
.field--error input, .field--error select { border-color: var(--danger); }
.field--check label { display: flex; align-items: center; gap: var(--sp-2); font-weight: 500; }
.field--check input { width: auto; }
.req { color: var(--danger); }
.form-actions { display: flex; justify-content: flex-end; gap: var(--sp-2); }
.form-note { font-size: var(--fs-xs); text-align: right; }
.inline-form { display: flex; gap: var(--sp-2); align-items: center; }
.inline-form select {
  font: inherit; font-size: var(--fs-sm); padding: .375rem var(--sp-2);
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface);
}
.messages .alert { margin-bottom: var(--sp-4); }


/* ---------- Matrículas e importación (Etapa 5) ---------- */
.badge--warning { color: var(--warning); background: var(--warning-bg); border-color: transparent; }
.badge--info { color: var(--info); background: var(--info-bg); border-color: transparent; }
.badge--danger { color: var(--danger); background: var(--danger-bg); border-color: transparent; }
.content > * + .card, .content > * + section, .content > * + form.card { margin-top: var(--sp-4); }
.steps { list-style: none; display: flex; gap: var(--sp-2); margin: 0 0 var(--sp-5); padding: 0; flex-wrap: wrap; }
.step { display: flex; align-items: center; gap: var(--sp-2); font-size: var(--fs-sm); color: var(--text-soft);
  padding: var(--sp-2) var(--sp-3); border-radius: 999px; background: var(--surface); border: 1px solid var(--border); }
.step span { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center;
  font-size: var(--fs-xs); font-weight: 600; background: var(--bg); color: var(--text-muted); }
.step.is-current { color: var(--brand-700); border-color: var(--brand-100); background: var(--brand-50); font-weight: 600; }
.step.is-current span { background: var(--brand-600); color: #fff; }
.step.is-done { color: var(--success); }
.step.is-done span { background: var(--success-bg); color: var(--success); }
.flow-summary { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-3) var(--sp-6); padding: var(--sp-3) var(--sp-5); }
.flow-summary > div { display: flex; flex-direction: column; font-size: var(--fs-sm); }
.flow-summary small { color: var(--text-muted); font-size: var(--fs-xs); }
.flow-summary a { font-size: var(--fs-xs); }
.flow-summary__cancel { margin-left: auto; }
.choice-list { display: grid; gap: var(--sp-2); }
.choice { display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-3) var(--sp-4);
  border: 1px solid var(--border); border-radius: var(--radius-sm); cursor: pointer; }
.choice:hover { background: var(--bg); }
.choice:has(input:checked) { border-color: var(--brand-600); background: var(--brand-50); }
.choice__body { display: flex; flex-direction: column; flex: 1; }
.choice input { width: auto; }
.empty-inline { padding: var(--sp-5); text-align: center; display: grid; gap: var(--sp-3); justify-items: center; }
.table-footer { padding: var(--sp-3) var(--sp-5); font-size: var(--fs-sm); color: var(--text-muted); margin: 0; }
.section-title { font-size: var(--fs-lg); font-weight: 600; margin-top: var(--sp-6); }
.subtitle { font-size: var(--fs-sm); font-weight: 600; margin-bottom: var(--sp-2); }
.plain-list { margin: 0; padding-left: var(--sp-5); font-size: var(--fs-sm); display: grid; gap: var(--sp-1); }
.confirm-card { max-width: 720px; display: grid; gap: var(--sp-3); }
.continue-card { display: flex; flex-wrap: wrap; align-items: flex-end; gap: var(--sp-4); }
.continue-card .alert { margin: 0; flex: 1 1 100%; align-items: center; justify-content: space-between; }
.field--inline { max-width: 220px; }
.detail-grid--flat { margin-top: var(--sp-2); }
.data--summary { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.empty-state__icon--success { background: var(--success-bg); color: var(--success); }
.form-actions--center { justify-content: center; }
.center-note { text-align: center; margin-top: var(--sp-5); }
.filters--single { grid-template-columns: minmax(0, 1fr) auto; }
.filters--bare { padding: 0; border: 0; box-shadow: none; margin: var(--sp-3) 0; }
.field input.precargado, .field select.precargado { background: var(--warning-bg); border-color: #e6cf98; }
.alert { justify-content: space-between; align-items: center; flex-wrap: wrap; }
.alert form { margin: 0; }
.diff-table td { vertical-align: top; }
.diff-old { color: var(--text-muted); text-decoration: line-through; }
.diff-new { color: var(--success); font-weight: 600; }
.counts { display: flex; flex-wrap: wrap; gap: var(--sp-2); margin-bottom: var(--sp-4); }

/* ---------- Estados de interacción: hover, presión, deshabilitado y envío ---------- */
.btn, .icon-btn, .nav-link, .quick-action, .quick-action__icon, .choice, .dropdown__item, .profile__toggle,
.table tbody tr, .field input, .field select, .field textarea, .inline-form select {
  transition: background-color var(--dur-hover) ease, border-color var(--dur-hover) ease,
              color var(--dur-hover) ease, box-shadow var(--dur-hover) ease;
}
.btn, .icon-btn { transition-property: background-color, border-color, color, box-shadow, transform; }
.btn:active:not(:disabled), .icon-btn:active { transform: scale(0.97); transition-duration: var(--dur-press); }

.btn:disabled { opacity: .6; cursor: not-allowed; }
.btn--secondary:hover { border-color: var(--text-soft); }
.quick-action:hover .quick-action__icon { color: var(--brand-600); }
.quick-action--primary:hover .quick-action__icon { color: #fff; background: var(--brand-700); }
.field input:hover:not(:focus), .field select:hover:not(:focus), .field textarea:hover:not(:focus) { border-color: var(--text-soft); }

/* Botón mientras se envía el formulario (lo activa app.js) */
.btn.is-loading { opacity: 1; cursor: progress; }
.btn.is-loading .icon { display: none; }
.btn.is-loading::before {
  content: ""; width: 1em; height: 1em; flex: none; border-radius: 50%;
  border: 2px solid currentColor; border-right-color: transparent;
  animation: girar .6s linear infinite;
}
@keyframes girar { to { transform: rotate(360deg); } }
form[aria-busy=true] { cursor: progress; }

/* En pantallas táctiles el hover se queda «pegado» tras tocar: se neutraliza. */
@media (hover: none) {
  .btn--primary:hover { background: var(--brand-600); }
  .btn--ghost:hover, .icon-btn:hover, .nav-link:hover:not(.is-active),
  .choice:hover:not(:has(input:checked)), .dropdown__item:hover { background: transparent; }
  .btn--secondary:hover { background: var(--surface); border-color: var(--border-strong); }
  .quick-action:hover { border-color: var(--border); background: transparent; }
}

/* ---------- Estado vacío de listados y secciones (partials/vacio.html) ---------- */
.table-vacio { padding: 0; border-bottom: 0; }
.vacio {
  display: grid; justify-items: center; gap: var(--sp-1); text-align: center;
  padding: var(--sp-6) var(--sp-4); max-width: 460px; margin: 0 auto;
}
.vacio__icono {
  width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center;
  background: var(--bg); color: var(--text-soft); margin-bottom: var(--sp-2);
}
.vacio__titulo { font-weight: 600; color: var(--text); }
.vacio__texto { color: var(--text-muted); font-size: var(--fs-sm); }
.vacio__acciones { display: flex; flex-wrap: wrap; justify-content: center; gap: var(--sp-2); margin-top: var(--sp-3); }

/* ---------- Responsive ---------- */
@media (max-width: 1200px) {
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-2 { grid-template-columns: minmax(0, 1fr); }
  .filters { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .filters__search { grid-column: 1 / -1; }
}

@media (max-width: 960px) {
  .detail-grid { grid-template-columns: minmax(0, 1fr); }
}

/* Tablet y teléfono: la barra lateral se vuelve un panel deslizable */
@media (max-width: 960px) {
  .app-main { margin-left: 0; }
  .sidebar { transform: translateX(-100%); transition: transform .2s ease; box-shadow: var(--shadow-lg); }
  body.sidebar-open .sidebar { transform: none; }
  .sidebar .sidebar__close, .topbar .topbar__menu { display: inline-grid; }
  .topbar { padding: 0 var(--sp-4); }
  .content { padding: var(--sp-5) var(--sp-4); }
}

@media (max-width: 600px) {
  .stats { grid-template-columns: minmax(0, 1fr); }
  .profile__name, .area-chip { display: none; }
  .page-header { align-items: stretch; }
  .page-actions, .page-actions .btn { width: 100%; }
  .page-actions { flex-direction: column; }
  .filters, .field-grid, .data { grid-template-columns: minmax(0, 1fr); }
  .form-actions { flex-direction: column-reverse; }
  .form-actions .btn { width: 100%; }
  .card__header { flex-wrap: wrap; }
  .inline-form { flex-wrap: wrap; }
  .hide-sm { display: none; }
  .data--summary { grid-template-columns: minmax(0, 1fr); }
  .flow-summary__cancel { margin-left: 0; }
  .step { font-size: var(--fs-xs); }
  .table th { white-space: normal; }
  .page-title { font-size: var(--fs-lg); }
  .stat__value { font-size: var(--fs-xl); }
  /* Con menos de 16 px, Safari en iPhone acerca la página al tocar un campo. */
  .field input, .field select, .field textarea, .inline-form select { font-size: 16px; }
}

/* Sin el destello gris al tocar en pantallas táctiles: los botones ya tienen su propio estado de presión. */
a, button, .choice { -webkit-tap-highlight-color: transparent; }

@media (prefers-reduced-motion: reduce) {
  .sidebar { transition: none; }
  .btn:active:not(:disabled), .icon-btn:active { transform: none; }
  .btn.is-loading::before { animation-duration: 1.5s; }
}

/* Recuadro de firma (contratos: firma capturada con tableta gráfica) */
.firma-pad { position: relative; margin: 1rem 0; border: 2px dashed var(--border-strong); border-radius: 8px;
  background: #fff; touch-action: none; }
.firma-pad canvas { display: block; width: 100%; height: auto; aspect-ratio: 3 / 1; cursor: crosshair; touch-action: none; }
.firma-pad__linea { position: absolute; left: 8%; right: 8%; bottom: 22%; border-bottom: 1px solid #9aa3ad;
  pointer-events: none; }

/* Foto del estudiante (ficha y pantalla de captura) */
.foto-ficha { display: flex; gap: 1rem; align-items: center; }
.foto-ficha__imagen, .foto-ficha__vacia { width: 96px; height: 120px; border-radius: 8px; object-fit: cover; flex: none;
  border: 1px solid var(--border-strong); background: var(--border); }
.foto-ficha__vacia { display: grid; place-items: center; color: var(--border-strong); }
.foto-ficha__vacia .icon { width: 40px; height: 40px; }
.foto-captura { display: flex; flex-wrap: wrap; gap: 1.5rem; align-items: flex-start; margin-bottom: 1rem; }
.foto-captura__vista { width: 320px; max-width: 100%; aspect-ratio: 4 / 3; display: grid; place-items: center;
  border: 2px dashed var(--border-strong); border-radius: 8px; overflow: hidden; background: #fff; }
.foto-captura__vista video, .foto-captura__vista img { width: 100%; height: 100%; object-fit: cover; }
.foto-captura__acciones { display: flex; flex-direction: column; gap: .5rem; flex: 1 1 240px; }

/* ==========================================================================
   Capa editorial (19/11/2026): se toma de la referencia de diseño la estructura, no la identidad.
   Se conservan el verde de CEDER, el logo y la fuente del sistema. Se adoptan:
   - lienzo cálido y tarjetas blancas con borde fino, sin sombras;
   - esquinas de 16 px en tarjetas y 10 px en botones y campos;
   - títulos grandes con peso ligero (500) y letras más juntas;
   - barra superior translúcida con desenfoque;
   - más aire entre secciones y enlaces que se subrayan al pasar el cursor.
   ========================================================================== */
body { -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }

.page-title { font-size: 1.875rem; font-weight: var(--fw-titulo); letter-spacing: var(--ls-titulo); line-height: 1.15; }
.page-header { margin-bottom: var(--sp-6); }
.card__title, .form-section__title { font-size: 1.0625rem; font-weight: 600; letter-spacing: -.005em; }
.section-title { font-size: 1.375rem; font-weight: var(--fw-titulo); letter-spacing: -.015em; }
.stat__value { font-weight: var(--fw-titulo); letter-spacing: -.02em; }
.auth-card__title { font-size: 1.5rem; font-weight: var(--fw-titulo); letter-spacing: -.015em; }

.card { border-radius: var(--radius); box-shadow: none; }
.content > .card + .card, .content > .card + section, .detail-grid + .card,
.content > * + .card, .content > * + section, .content > * + form.card { margin-top: var(--sp-5); }
.detail-grid, .form-sections, .stats { gap: var(--sp-5); }
.auth-card { box-shadow: none; }

.btn { border-radius: 10px; padding: .625rem 1.125rem; }
.btn--sm { border-radius: var(--radius-sm); }
.field input, .field select, .field textarea, .inline-form select { border-radius: 10px; }
.field input:focus, .field select:focus, .field textarea:focus { box-shadow: 0 0 0 3px var(--brand-100); }

/* Barra superior translúcida: el contenido se ve pasar debajo, desenfocado */
.topbar {
  background: rgba(244, 243, 239, .82);
  -webkit-backdrop-filter: saturate(140%) blur(12px); backdrop-filter: saturate(140%) blur(12px);
}
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .topbar { background: var(--bg); }
}
.sidebar { background: var(--surface); }

/* Tablas: encabezado discreto sobre el lienzo, líneas finas */
.table th { background: transparent; color: var(--text-soft); border-bottom-color: var(--border); }
.card--flush .table thead tr { background: var(--bg); }

/* Enlaces: subrayado suave al pasar el cursor */
a { text-underline-offset: 3px; text-decoration-thickness: 1px; }
a:hover { text-decoration-color: currentColor; }
.btn:hover, .nav-link:hover, .quick-action:hover, .dropdown__item:hover { text-decoration: none; }

/* Pastillas y pasos con la misma forma redondeada */
.badge { padding: 2px var(--sp-3); }
.quick-action, .choice { border-radius: 12px; }
.notice, .alert { border-radius: 12px; }
.dropdown { border-radius: 14px; }

@media (max-width: 600px) {
  .page-title { font-size: 1.5rem; }
  .detail-grid, .form-sections, .stats { gap: var(--sp-4); }
}
.detail-grid + .detail-grid, .detail-grid + section, .card + .detail-grid { margin-top: var(--sp-5); }
@media (max-width: 600px) { .detail-grid + .detail-grid, .detail-grid + section, .card + .detail-grid { margin-top: var(--sp-4); } }

/* Listas de casillas y opciones (CheckboxSelectMultiple / RadioSelect): cada opción en una fila, casilla a la izquierda */
.field input[type=checkbox], .field input[type=radio] { width: auto; padding: 0; accent-color: var(--brand-600); }
.field div[id^="id_"] { display: grid; gap: var(--sp-2); }
.field div[id^="id_"] > div > label {
  display: flex; align-items: center; gap: var(--sp-3); font-weight: 500; font-size: var(--fs-sm);
  padding: var(--sp-3) var(--sp-4); border: 1px solid var(--border); border-radius: 12px; background: var(--surface); cursor: pointer;
}
.field div[id^="id_"] > div > label:has(input:checked) { border-color: var(--brand-600); background: var(--brand-50); }
.page-title, .card__title { overflow-wrap: anywhere; }

/* Páginas de error (templates/errores/base.html) */
.error-card { max-width: 480px; }
.error-card__codigo { font-size: var(--fs-xs); font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--text-soft); margin-bottom: var(--sp-2); }
.error-card__texto { display: grid; gap: var(--sp-3); margin: var(--sp-3) 0 var(--sp-5); }
.error-card__texto .muted { margin-bottom: 0; }
.error-card__acciones { display: flex; flex-wrap: wrap; gap: var(--sp-2); }
@media (max-width: 600px) { .error-card__acciones .btn { flex: 1 1 100%; } }

/* ---------- Ícono «i» de ayuda de cada campo (apps/core/templatetags/ayuda.py) ---------- */
.field__head { display: flex; align-items: center; gap: 6px; min-width: 0; }
.field__head > label { min-width: 0; }
.ayuda { position: relative; display: inline-flex; flex: none; }
.ayuda__boton {
  width: 18px; height: 18px; padding: 0; border-radius: 50%;
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text-muted);
  font: italic 700 11px/1 Georgia, "Times New Roman", serif; cursor: help;
  display: inline-flex; align-items: center; justify-content: center;
}
.ayuda__boton:hover, .ayuda.is-open .ayuda__boton { border-color: var(--brand-600); color: var(--brand-700); background: var(--brand-50); }
.ayuda__boton:focus-visible { outline: 2px solid var(--brand-600); outline-offset: 2px; }
.ayuda__texto {
  position: absolute; z-index: 60; bottom: calc(100% + 8px); left: -10px;
  width: max-content; max-width: min(300px, calc(100vw - 32px));
  padding: 8px 10px; border-radius: var(--radius-sm); background: var(--text); color: #fff;
  font-size: 13px; font-weight: 400; line-height: 1.4; text-align: left; white-space: normal;
  box-shadow: var(--shadow-lg); pointer-events: none;
  opacity: 0; visibility: hidden; transform: translateY(2px);
  transition: opacity .12s ease, transform .12s ease, visibility 0s linear .12s;
}
.ayuda:hover .ayuda__texto, .ayuda:focus-within .ayuda__texto, .ayuda.is-open .ayuda__texto {
  opacity: 1; visibility: visible; transform: none; transition-delay: 0s;
}
@media (prefers-reduced-motion: reduce) { .ayuda__texto { transition: none; } }

/* ---------- Botón «Reportar problema» del encabezado de cada sección ---------- */
.btn-reportar { border: 1px solid var(--border); color: var(--text-muted); align-self: center; }
