/* =========================================================================
   Correspondencia — Sistema de Gestion Institucional
   Hoja de estilos propia (sin frameworks externos, sin CDN).
   ========================================================================= */

:root {
  --color-primary: #721a32;
  --color-primary-dark: #460b1c;
  --color-primary-light: #faeef1;
  --color-accent: #9d2946;

  --color-ink: #1f2328;
  --color-ink-soft: #4b5563;
  --color-ink-faint: #7c8591;

  --color-bg: #f6f4f5;
  --color-surface: #ffffff;
  --color-border: #e7e0e2;
  --color-border-strong: #d5cace;

  --color-success-bg: #e7f6ec;
  --color-success-ink: #1e7a3d;
  --color-warning-bg: #fdf3e0;
  --color-warning-ink: #9a6400;
  --color-danger-bg: #fbe9ea;
  --color-danger-ink: #a3222e;
  --color-info-bg: #eaf3fb;
  --color-info-ink: #23628f;
  --color-neutral-bg: #eef0f3;
  --color-neutral-ink: #4b5563;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 18px;

  --shadow-sm: 0 1px 2px rgba(31, 35, 40, 0.06);
  --shadow-md: 0 4px 14px rgba(31, 35, 40, 0.08);

  --header-height: 68px;
  --sidebar-width: 264px;
  --sidebar-width-collapsed: 72px;

  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-sans);
  color: var(--color-ink);
  background: var(--color-bg);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  font-family: inherit;
}

h1, h2, h3, h4 {
  margin: 0 0 0.4em;
  font-weight: 600;
  color: var(--color-ink);
}

/* -------------------------------------------------------------------------
   Accesibilidad: skip-link y foco visible
   ------------------------------------------------------------------------- */

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--color-primary);
  color: #fff;
  padding: 10px 16px;
  z-index: 1000;
  border-radius: 0 0 var(--radius-sm) 0;
}

.skip-link:focus {
  left: 0;
}

:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

/* -------------------------------------------------------------------------
   Layout general
   ------------------------------------------------------------------------- */

.app-shell {
  display: flex;
  min-height: calc(100vh - var(--header-height));
}

/* -------------------------------------------------------------------------
   Header
   ------------------------------------------------------------------------- */

.app-header {
  height: var(--header-height);
  background: linear-gradient(110deg, #781b35 0%, var(--color-primary) 48%, var(--color-primary-dark) 100%);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 100;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 3px 16px rgba(54, 8, 23, 0.2);
}

.app-header__brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.app-header__toggle {
  display: none;
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.35);
  color: #fff;
  border-radius: var(--radius-sm);
  padding: 6px 8px;
  cursor: pointer;
}

.app-header__mark {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.13);
  border: 1px solid rgba(255, 255, 255, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.app-header__titles {
  line-height: 1.15;
}

.app-header__name {
  font-weight: 700;
  font-size: 1.08rem;
  letter-spacing: 0.04em;
}

.app-header__subtitle {
  font-size: 0.72rem;
  color: rgba(255, 255, 255, 0.78);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.app-header__session {
  display: flex;
  align-items: center;
  gap: 14px;
}

.app-header__unit {
  text-align: right;
  font-size: 0.78rem;
  color: rgba(255, 255, 255, 0.82);
  line-height: 1.3;
}

.app-header__unit strong {
  display: block;
  color: #fff;
  font-size: 0.85rem;
}

.app-header__user {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(35, 4, 14, 0.16);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 999px;
  padding: 6px 14px 6px 6px;
  cursor: default;
}

.app-header__avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: #fff;
  color: var(--color-primary-dark);
  font-weight: 700;
  font-size: 0.8rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.app-header__user-name {
  font-size: 0.85rem;
  font-weight: 600;
  line-height: 1.1;
}

.app-header__user-role {
  font-size: 0.7rem;
  color: rgba(255, 255, 255, 0.75);
}

.app-header__dev-badge {
  font-size: 0.62rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: rgba(255, 255, 255, 0.22);
  padding: 2px 7px;
  border-radius: 999px;
  margin-left: 6px;
}

/* -------------------------------------------------------------------------
   Sidebar
   ------------------------------------------------------------------------- */

.app-sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  color: #fff;
  background: linear-gradient(180deg, #3d0a18 0%, #5b1127 48%, #310713 100%);
  border-right: 1px solid rgba(67, 8, 25, 0.4);
  padding: 18px 12px 22px;
  position: sticky;
  top: var(--header-height);
  align-self: flex-start;
  height: calc(100vh - var(--header-height));
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.3) transparent;
}

.app-sidebar::-webkit-scrollbar {
  width: 7px;
}

.app-sidebar::-webkit-scrollbar-track {
  background: transparent;
}

.app-sidebar::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.3);
  border: 2px solid transparent;
  border-radius: 999px;
}

.app-nav__group-label {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: rgba(255, 255, 255, 0.54);
  padding: 5px 11px 9px;
}

.app-nav__list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.app-nav__link {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 40px;
  padding: 9px 11px;
  border-radius: var(--radius-md);
  color: rgba(255, 255, 255, 0.82);
  font-size: 0.88rem;
  font-weight: 500;
  line-height: 1.25;
  transition: background 0.16s ease, color 0.16s ease;
}

.app-nav__link svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  opacity: 0.9;
}

.app-nav__link:hover {
  background: rgba(255, 255, 255, 0.09);
  color: #fff;
}

.app-nav__item--active > .app-nav__link {
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  font-weight: 600;
  box-shadow: inset 3px 0 0 #efbdc8;
}

.app-nav__label {
  min-width: 0;
  flex: 1;
}

.app-nav__item--disabled .app-nav__link {
  color: rgba(255, 255, 255, 0.42);
  cursor: default;
}

.app-nav__item--disabled .app-nav__link:hover {
  background: transparent;
  color: rgba(255, 255, 255, 0.42);
}

.app-nav__soon {
  margin-left: auto;
  font-size: 0.6rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: var(--color-neutral-bg);
  color: var(--color-ink-faint);
  padding: 2px 6px;
  border-radius: 999px;
}

/* -------------------------------------------------------------------------
   Contenido principal
   ------------------------------------------------------------------------- */

.app-main {
  flex: 1;
  min-width: 0;
  padding: 26px 32px 52px;
  background: var(--color-surface);
}

.breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.82rem;
  color: var(--color-ink-faint);
  margin-bottom: 14px;
}

.breadcrumb a {
  color: var(--color-ink-soft);
}

.breadcrumb a:hover {
  color: var(--color-primary);
}

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
  flex-wrap: wrap;
}

.page-header__titles h1 {
  font-size: clamp(1.55rem, 2vw, 1.9rem);
  line-height: 1.2;
  letter-spacing: -0.02em;
}

.page-header__titles p {
  margin: 2px 0 0;
  color: var(--color-ink-soft);
  font-size: 0.94rem;
}

/* -------------------------------------------------------------------------
   Botones
   ------------------------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border-radius: var(--radius-sm);
  padding: 10px 16px;
  font-size: 0.88rem;
  font-weight: 600;
  border: 1px solid transparent;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color 0.16s ease, border-color 0.16s ease, color 0.16s ease, transform 0.16s ease;
}

.btn-primary {
  background: var(--color-primary);
  color: #fff;
}

.btn-primary:hover {
  background: var(--color-primary-dark);
}

.btn-success {
  background: var(--color-success-ink);
  color: #fff;
}

.btn-success:hover {
  background: #155f2e;
}

.btn-secondary {
  background: var(--color-surface);
  color: var(--color-ink-soft);
  border-color: var(--color-border-strong);
}

.btn-secondary:hover {
  border-color: var(--color-primary);
  color: var(--color-primary);
}

.btn[disabled],
.btn.is-disabled {
  background: var(--color-neutral-bg);
  color: var(--color-ink-faint);
  cursor: not-allowed;
  border-color: var(--color-border);
}

.btn[disabled]:hover,
.btn.is-disabled:hover {
  background: var(--color-neutral-bg);
  color: var(--color-ink-faint);
}

/* -------------------------------------------------------------------------
   Tarjetas / KPIs
   ------------------------------------------------------------------------- */

.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: 0 2px 8px rgba(58, 27, 37, 0.05);
}

.card__header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.card__header h2 {
  font-size: 1.02rem;
  margin: 0;
}

.card__body {
  padding: 20px;
}

.detail-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px 24px;
  margin: 0;
}

.detail-list dt {
  font-size: 0.78rem;
  color: var(--color-ink-faint);
  margin-bottom: 2px;
}

.detail-list dd {
  margin: 0;
  font-size: 0.92rem;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 22px;
}

.kpi-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  box-shadow: var(--shadow-sm);
}

.kpi-card__label {
  font-size: 0.78rem;
  color: var(--color-ink-soft);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.kpi-card__value {
  font-size: 2rem;
  font-weight: 700;
  margin-top: 6px;
  color: var(--color-ink);
}

.kpi-card--pendientes { border-top: 3px solid var(--color-neutral-ink); }
.kpi-card--atencion   { border-top: 3px solid var(--color-warning-ink); }
.kpi-card--concluidas { border-top: 3px solid var(--color-success-ink); }
.kpi-card--vencidas   { border-top: 3px solid var(--color-danger-ink); }

/* -------------------------------------------------------------------------
   Filtros / buscador
   ------------------------------------------------------------------------- */

.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}

.search-field {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--color-surface);
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  flex: 1 1 260px;
  color: var(--color-ink-faint);
}

.search-field input {
  border: none;
  outline: none;
  flex: 1;
  font-size: 0.9rem;
  color: var(--color-ink);
  background: transparent;
}

.filter-select {
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  font-size: 0.86rem;
  color: var(--color-ink-soft);
  background: var(--color-surface);
}

/* -------------------------------------------------------------------------
   Tablas
   ------------------------------------------------------------------------- */

.table-shell {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

.table-shell thead th {
  text-align: left;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-ink-faint);
  padding: 10px 14px;
  border-bottom: 1px solid var(--color-border);
  white-space: nowrap;
}

.table-shell tbody td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--color-border);
  color: var(--color-ink-soft);
}

.table-shell tbody tr:last-child td {
  border-bottom: none;
}

.table-shell tbody tr {
  transition: background-color 0.14s ease;
}

.table-shell tbody tr:hover {
  background: #fcf8f9;
}

/* -------------------------------------------------------------------------
   Estado vacio
   ------------------------------------------------------------------------- */

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 56px 20px;
  color: var(--color-ink-faint);
}

.empty-state svg {
  opacity: 0.55;
  margin-bottom: 14px;
}

.empty-state__title {
  font-size: 0.98rem;
  font-weight: 600;
  color: var(--color-ink-soft);
  margin-bottom: 4px;
}

.empty-state__hint {
  font-size: 0.84rem;
  max-width: 360px;
}

/* -------------------------------------------------------------------------
   Badges de estado
   ------------------------------------------------------------------------- */

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.76rem;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 999px;
  white-space: nowrap;
}

.status-badge--neutral { background: var(--color-neutral-bg); color: var(--color-neutral-ink); }
.status-badge--success { background: var(--color-success-bg); color: var(--color-success-ink); }
.status-badge--warning { background: var(--color-warning-bg); color: var(--color-warning-ink); }
.status-badge--danger  { background: var(--color-danger-bg); color: var(--color-danger-ink); }
.status-badge--info    { background: var(--color-info-bg); color: var(--color-info-ink); }

/* -------------------------------------------------------------------------
   Mensajes flash
   ------------------------------------------------------------------------- */

.flash-container {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 16px;
}

.flash-message {
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  font-size: 0.88rem;
  border: 1px solid transparent;
}

.flash-message--info {
  background: var(--color-primary-light);
  color: var(--color-primary-dark);
  border-color: #f0c8cb;
}

/* -------------------------------------------------------------------------
   Formulario (maqueta de registro)
   ------------------------------------------------------------------------- */

.notice-banner {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  background: var(--color-warning-bg);
  color: var(--color-warning-ink);
  border: 1px solid #f2dfb0;
  border-radius: var(--radius-md);
  padding: 14px 16px;
  font-size: 0.86rem;
  margin-bottom: 20px;
}

.notice-banner--success {
  background: var(--color-success-bg);
  color: var(--color-success-ink);
  border-color: #bfe5cc;
}

.notice-banner--danger {
  background: var(--color-danger-bg);
  color: var(--color-danger-ink);
  border-color: #f0c8cb;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px 20px;
}

/* Modulo Personal (Fase 1): pares etiqueta/valor de solo lectura dentro de
   una tarjeta de expediente (datos personales, contacto). */
.definition-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px 24px;
  margin: 12px 0;
}

.definition-grid dt {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--color-ink-faint);
  margin: 0;
}

.definition-grid dd {
  margin: 2px 0 0;
  font-size: 0.92rem;
  color: var(--color-ink);
}

.form-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-field--full {
  grid-column: 1 / -1;
}

.form-field label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--color-ink-soft);
}

.form-field .hint {
  font-size: 0.74rem;
  color: var(--color-ink-faint);
}

.form-field input[type="text"],
.form-field input[type="date"],
.form-field input[type="datetime-local"],
.form-field input[type="email"],
.form-field input[type="file"],
.form-field select,
.form-field textarea {
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 0.88rem;
  font-family: inherit;
  color: var(--color-ink);
  background: var(--color-surface);
  width: 100%;
}

.form-field textarea {
  resize: vertical;
  min-height: 84px;
}

.form-field input:disabled,
.form-field select:disabled,
.form-field textarea:disabled {
  background: var(--color-bg);
  color: var(--color-ink-faint);
}

.form-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--color-border);
}

.form-actions__note {
  font-size: 0.78rem;
  color: var(--color-ink-faint);
}

/* -------------------------------------------------------------------------
   Footer
   ------------------------------------------------------------------------- */

.app-footer {
  text-align: center;
  font-size: 0.76rem;
  color: var(--color-ink-faint);
  padding: 18px 20px 26px;
}

/* -------------------------------------------------------------------------
   Responsive
   ------------------------------------------------------------------------- */

@media (max-width: 960px) {
  .kpi-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .form-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 820px) {
  .app-header__toggle {
    display: inline-flex;
    align-items: center;
  }

  .app-header__unit {
    display: none;
  }

  .app-sidebar {
    position: fixed;
    left: -100%;
    top: var(--header-height);
    z-index: 90;
    width: min(80vw, 300px);
    height: calc(100vh - var(--header-height));
    box-shadow: var(--shadow-md);
    transition: left 0.18s ease;
  }

  .app-sidebar.is-open {
    left: 0;
  }

  .app-main {
    padding: 18px 16px 40px;
  }
}

@media (max-width: 560px) {
  .app-header {
    gap: 8px;
    padding: 0 10px;
  }

  .app-header__brand {
    min-width: 0;
    gap: 8px;
  }

  .app-header__subtitle,
  .app-header__user > span:not(.app-header__avatar),
  .app-header__user > svg {
    display: none;
  }

  .app-header__name {
    font-size: .98rem;
  }

  .app-header__session {
    flex: 0 0 auto;
    gap: 6px;
    margin-left: auto;
  }

  .app-header__user {
    gap: 0;
    padding: 5px;
  }

  .kpi-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 380px) {
  .app-header__mark {
    display: none;
  }
}

/* =========================================================================
   Autenticación (Fase 7A) — evolución visual del login institucional SIIGE.

   Composición split-screen: fotografía institucional con overlay guinda al
   izquierda (identidad y lema) y panel guinda profundo con la tarjeta de
   autenticación a la derecha. Sin frameworks ni CDN: la fotografía y la
   textura del panel se sirven de assets/images/backgrounds con WebP y
   respaldo PNG vía image-set().
   ========================================================================= */

.auth-body {
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  background: #2f0e15;
}

.auth-shell {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(480px, 620px);
}

/* Tamaño de los iconos decorativos del login (el SVG base mide 20px). */
.icon--lg {
  width: 28px;
  height: 28px;
}

.icon--xs {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

/* — Panel institucional (izquierda) — */

.auth-hero {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  gap: 40px;
  padding: 44px clamp(32px, 3.5vw, 56px);
  overflow: hidden;
  background-color: #341017;
  background-image: image-set(
    url("../images/backgrounds/login-premium.webp") type("image/webp"),
    url("../images/backgrounds/login-premium.png") type("image/png")
  );
  /* Composición natural: cover conserva completos a la docente, los
     estudiantes y el edificio; el recorte es lateral, nunca vertical.
     Desaturación mínima para un acabado sobrio, sin filtros de color. */
  background-size: cover;
  background-position: 42% 38%;
  background-repeat: no-repeat;
  filter: saturate(0.95);
}

/* Transición neutral corta (~13% del ancho): un velo negro cálido apenas
   percibido que entrega la fotografía directamente en el vino oscuro y
   uniforme del panel. Sin azules, sin púrpuras, sin saltos de color. */
.auth-hero::after {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: max(90px, 13%);
  background: linear-gradient(
    to right,
    rgba(24, 18, 19, 0) 0%,
    rgba(24, 18, 19, 0.2) 45%,
    rgba(24, 18, 19, 0.45) 78%,
    #341017 100%
  );
}

/* — Panel de autenticación (derecha) —
   Un solo vino oscuro, apagado y uniforme (#341017): sin glow, sin
   textura y sin degradados. El fondo acompaña a la tarjeta sin competir
   con ella; su color coincide con el final de la transición del héroe. */
.auth-panel {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 56px clamp(20px, 4vw, 64px);
  background: #341017;
}

/* — Tarjeta de autenticación — */

.auth-card {
  position: relative;
  z-index: 1;
  width: min(440px, 100%);
  padding: 40px 38px 34px;
  border-radius: var(--radius-xl);
  border: none;
  /* Sombra en tres planos (contacto, cuerpo y ambiente) + aro claro: la
     tarjeta se aprecia elevada del fondo, no estampada sobre él. */
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.1),
    0 1px 2px rgba(22, 3, 8, 0.18),
    0 12px 28px -6px rgba(22, 3, 8, 0.25),
    0 36px 90px -12px rgba(22, 3, 8, 0.45);
  animation: authCardIn 0.5s cubic-bezier(0.21, 0.75, 0.35, 1) both;
}

/* Acento institucional superior. */
.auth-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 34px;
  right: 34px;
  height: 3px;
  border-radius: 0 0 3px 3px;
  background: linear-gradient(90deg, var(--color-primary), var(--color-accent));
}

.auth-card__brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 22px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--color-border);
}

.auth-card__mark {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: var(--color-primary);
  background: var(--color-primary-light);
}

.auth-card__name {
  font-weight: 800;
  font-size: 1.02rem;
  letter-spacing: 0.05em;
  line-height: 1.15;
  color: var(--color-ink);
}

.auth-card__subtitle {
  margin-top: 2px;
  max-width: 250px;
  font-size: 0.66rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  line-height: 1.5;
  color: var(--color-ink-faint);
}

.auth-card__heading {
  margin: 0 0 4px;
  font-size: 1.32rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.auth-card__lead {
  margin: 0 0 24px;
  font-size: 0.88rem;
  color: var(--color-ink-soft);
}

.auth-card .notice-banner {
  margin: 0 0 20px;
  border-radius: var(--radius-md);
  font-size: 0.84rem;
}

.auth-card form {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.auth-card .form-field {
  margin: 0;
  gap: 7px;
}

.auth-card .form-field label {
  font-size: 0.84rem;
}

/* Campo con icono a la izquierda y control al ras del ancho de la tarjeta. */
.auth-control {
  position: relative;
}

.auth-control__icon {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  color: var(--color-ink-faint);
  pointer-events: none;
  transition: color 0.15s ease;
}

/* Los selectores llevan .auth-card para ganarle en especificidad a la
   regla genérica .form-field input[type=text] (que de lo contrario
   aplasta el padding del icono y el radio del campo de usuario). */
.auth-card .auth-control input {
  width: 100%;
  height: 48px;
  padding: 0 14px 0 48px;
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-md);
  background: #fafbfc;
  color: var(--color-ink);
  font-size: 0.95rem;
  font-family: inherit;
  line-height: normal;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.auth-card .auth-control input::placeholder {
  color: var(--color-ink-faint);
}

.auth-card .auth-control input:hover {
  border-color: #b8bec8;
}

.auth-card .auth-control input:focus {
  outline: none;
  border-color: var(--color-primary);
  background: var(--color-surface);
  box-shadow: 0 0 0 3px rgba(122, 22, 32, 0.14);
}

.auth-control:focus-within .auth-control__icon {
  color: var(--color-primary);
}

/* Mostrar/ocultar contraseña. */
.auth-card .auth-control--password input {
  padding-right: 52px;
}

.auth-toggle {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  color: var(--color-ink-faint);
  cursor: pointer;
  transition: color 0.15s ease, background 0.15s ease;
}

.auth-toggle:hover {
  color: var(--color-primary);
  background: var(--color-primary-light);
}

.auth-toggle:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 1px;
}

.auth-toggle[aria-pressed="true"] {
  color: var(--color-primary);
  background: var(--color-primary-light);
}

.auth-toggle__icon {
  display: flex;
}

.auth-toggle__icon--off {
  display: none;
}

.auth-toggle[aria-pressed="true"] .auth-toggle__icon--on {
  display: none;
}

.auth-toggle[aria-pressed="true"] .auth-toggle__icon--off {
  display: flex;
}

/* Estado de error por campo. */
.auth-field--error .auth-control input {
  border-color: #c24552;
  background: #fdf7f7;
}

.auth-field--error .auth-control input:hover {
  border-color: #b23544;
}

.auth-field--error .auth-control input:focus {
  border-color: var(--color-danger-ink);
  box-shadow: 0 0 0 3px rgba(163, 34, 46, 0.14);
}

.auth-field--error .auth-control__icon {
  color: var(--color-danger-ink);
}

.auth-card .hint--error {
  display: flex;
  align-items: center;
  gap: 5px;
  color: var(--color-danger-ink);
  font-weight: 600;
}

/* Botón principal del login. */
.auth-card .btn--block {
  width: 100%;
  justify-content: center;
  height: 50px;
  margin-top: 8px;
  border-radius: var(--radius-md);
  font-size: 0.95rem;
  letter-spacing: 0.02em;
  background: linear-gradient(180deg, #862029, var(--color-primary));
  box-shadow:
    0 10px 22px rgba(92, 16, 24, 0.3),
    inset 0 1px 0 rgba(255, 255, 255, 0.08);
  transition: background 0.15s ease, box-shadow 0.15s ease, transform 0.1s ease;
}

.auth-card .btn--block:hover {
  background: linear-gradient(180deg, var(--color-primary), var(--color-primary-dark));
  box-shadow:
    0 12px 26px rgba(92, 16, 24, 0.38),
    inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.auth-card .btn--block:active {
  transform: translateY(1px);
  box-shadow: 0 6px 14px rgba(92, 16, 24, 0.3);
}

/* Pie del login: línea de entorno como nota discreta sobre el panel guinda. */
.app-footer--auth {
  position: absolute;
  right: 28px;
  bottom: 14px;
  left: auto;
  max-width: min(52ch, 56vw);
  padding: 0;
  color: rgba(255, 255, 255, 0.72);
  text-align: right;
  line-height: 1.4;
  z-index: 2;
}

/* — Animaciones — */

@keyframes authCardIn {
  from {
    opacity: 0;
    transform: translateY(14px) scale(0.985);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .auth-card {
    animation: none;
  }

  .auth-card .btn--block,
  .auth-control input,
  .auth-toggle {
    transition: none;
  }
}

/* =========================================================================
   Expediente de Personal
   ========================================================================= */

.expediente-page {
  max-width: 1440px;
  margin: 0 auto;
}

.worker-profile {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 20px;
  align-items: center;
  padding: 22px 24px;
  border: 1px solid #eadadd;
  border-top: 4px solid var(--color-primary);
  border-radius: var(--radius-lg);
  background: linear-gradient(135deg, #fff 0%, #fff 68%, #fbf5f6 100%);
  box-shadow: 0 5px 18px rgba(58, 27, 37, 0.07);
}

.worker-profile__photo {
  width: 112px;
  height: 112px;
  object-fit: cover;
  border: 4px solid #fff;
  border-radius: 18px;
  background: var(--color-neutral-bg);
  box-shadow: 0 0 0 1px var(--color-border), 0 5px 14px rgba(58, 27, 37, 0.12);
}

.worker-profile__identity { min-width: 0; }

.worker-profile__eyebrow {
  display: block;
  margin-bottom: 4px;
  color: var(--color-primary);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.worker-profile h1 {
  margin: 0;
  color: var(--color-ink);
  font-size: clamp(1.45rem, 2.6vw, 2rem);
  line-height: 1.16;
  letter-spacing: -0.025em;
}

.worker-profile__keys {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 20px;
  margin-top: 10px;
  color: var(--color-ink-soft);
  font-size: 0.88rem;
}

.worker-profile__keys strong {
  margin-right: 5px;
  color: var(--color-ink-faint);
  font-size: 0.72rem;
  letter-spacing: 0.05em;
}

.worker-profile__assignment {
  margin: 7px 0 0;
  color: var(--color-ink-soft);
  font-size: 0.9rem;
}

.worker-profile__statuses {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 12px;
}

.worker-profile__actions {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
}

.worker-profile__actions .btn { justify-content: center; }

.worker-profile__back {
  padding: 3px;
  color: var(--color-ink-faint);
  font-size: 0.8rem;
  text-align: center;
}

.worker-profile__back:hover { color: var(--color-primary); }

.record-nav {
  display: flex;
  gap: 7px;
  margin: 14px 0 18px;
  padding: 9px;
  overflow-x: auto;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: #fff;
  scrollbar-width: thin;
}

.record-nav a {
  flex: 0 0 auto;
  padding: 7px 11px;
  border-radius: var(--radius-sm);
  color: var(--color-ink-soft);
  font-size: 0.78rem;
  font-weight: 600;
}

.record-nav a:hover {
  background: var(--color-primary-light);
  color: var(--color-primary);
}

.record-stack {
  display: grid;
  gap: 14px;
}

.record-section { scroll-margin-top: calc(var(--header-height) + 14px); }

.record-section__header {
  min-height: 54px;
  padding: 13px 18px;
  background: #fdfafb;
}

.record-section__header > div {
  display: flex;
  align-items: center;
  gap: 10px;
}

.record-section__header p {
  margin: 0;
  color: var(--color-ink-faint);
  font-size: 0.78rem;
}

.record-section__number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 29px;
  height: 29px;
  border-radius: 8px;
  background: var(--color-primary-light);
  color: var(--color-primary);
  font-size: 0.72rem;
  font-weight: 700;
}

.record-section .card__body { padding: 16px 18px; }

.record-data-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0;
  margin: 0;
}

.record-data-grid--two { grid-template-columns: repeat(2, minmax(0, 1fr)); }

.record-data-grid > div {
  min-width: 0;
  padding: 8px 16px 10px 0;
  border-bottom: 1px solid #f0e8ea;
}

.record-data-grid dt {
  margin: 0 0 3px;
  color: var(--color-ink-faint);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.045em;
  text-transform: uppercase;
}

.record-data-grid dd {
  margin: 0;
  overflow-wrap: anywhere;
  color: var(--color-ink);
  font-size: 0.93rem;
  font-weight: 550;
}

.record-editor {
  margin-top: 14px;
  border-top: 1px solid var(--color-border);
}

.record-editor summary {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin-top: 11px;
  padding: 7px 0;
  color: var(--color-primary);
  font-size: 0.84rem;
  font-weight: 700;
  cursor: pointer;
  list-style: none;
}

.record-editor summary::-webkit-details-marker { display: none; }
.record-editor summary svg { width: 16px; height: 16px; }

.record-editor[open] summary { margin-bottom: 10px; }

.record-editor--addition summary {
  padding: 8px 12px;
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-sm);
  color: var(--color-ink-soft);
}

.record-form {
  padding: 16px;
  border: 1px solid #eadadd;
  border-radius: var(--radius-md);
  background: #fdfafb;
}

.expediente-page .form-field input:not([type="checkbox"]):not([type="radio"]),
.expediente-page .form-field select,
.expediente-page .form-field textarea {
  width: 100%;
  min-height: 42px;
  padding: 10px 12px;
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-sm);
  outline: none;
  background: #fff;
  color: var(--color-ink);
  font: inherit;
  font-size: 0.9rem;
  transition: border-color 0.16s ease, box-shadow 0.16s ease;
}

.expediente-page .form-field textarea {
  min-height: 82px;
  resize: vertical;
}

.expediente-page .form-field input:focus,
.expediente-page .form-field select:focus,
.expediente-page .form-field textarea:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(119, 30, 47, 0.12);
}

.record-form__actions {
  grid-column: 1 / -1;
  justify-content: flex-end;
  margin-top: 2px;
  padding-top: 14px;
}

.table-responsive {
  width: 100%;
  overflow-x: auto;
}

.record-section .table-shell td strong { color: var(--color-ink); }

.record-empty {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 5px 12px;
  padding: 7px 0;
  color: var(--color-ink-faint);
}

.record-empty strong { color: var(--color-ink-soft); font-size: 0.9rem; }
.record-empty span, .record-empty a { font-size: 0.82rem; }
.record-empty a { color: var(--color-primary); font-weight: 600; }

.record-subheading { margin: 16px 0 8px; font-size: 0.9rem; }
.record-summary { margin: 0 0 10px; color: var(--color-ink-soft); font-size: 0.88rem; }
.record-muted { margin: 12px 0 0; color: var(--color-ink-faint); font-size: 0.82rem; }
.record-inline-actions { display: flex; justify-content: flex-end; margin-top: 12px; }

.record-generate-form {
  display: flex;
  align-items: flex-end;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--color-border);
}

.record-generate-form .form-field { width: min(100%, 320px); }

@media (max-width: 1040px) {
  .worker-profile { grid-template-columns: auto minmax(0, 1fr); }
  .worker-profile__actions { grid-column: 1 / -1; flex-direction: row; justify-content: flex-end; align-items: center; }
  .worker-profile__back { order: -1; margin-right: auto; }
}

@media (max-width: 760px) {
  .worker-profile { grid-template-columns: 72px minmax(0, 1fr); padding: 18px; gap: 14px; }
  .worker-profile__photo { width: 72px; height: 72px; border-radius: 13px; }
  .worker-profile__keys { flex-direction: column; gap: 3px; }
  .worker-profile__actions { align-items: stretch; }
  .worker-profile__actions .btn { flex: 1 1 auto; }
  .record-data-grid, .record-data-grid--two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 520px) {
  .worker-profile { grid-template-columns: 1fr; }
  .worker-profile__photo { width: 82px; height: 82px; }
  .worker-profile__actions { flex-direction: column; }
  .worker-profile__back { order: 0; margin: 0; }
  .record-data-grid, .record-data-grid--two { grid-template-columns: 1fr; }
  .record-section__header { align-items: flex-start; }
  .record-section__header > p { width: 100%; padding-left: 39px; }
  .record-generate-form { align-items: stretch; flex-direction: column; }
  .record-generate-form .form-field { width: 100%; }
}

/* — Responsive — */

@media (max-width: 1240px) {
  .auth-shell {
    grid-template-columns: minmax(0, 1fr) minmax(440px, 520px);
  }

  .auth-hero {
    padding: 40px 36px;
  }
}

@media (max-width: 960px) {
  .auth-body,
  .auth-shell {
    min-height: 0;
  }

  .auth-shell {
    grid-template-columns: 1fr;
  }

  .auth-hero {
    min-height: 300px;
    padding: 32px 28px;
    background-size: cover;
    background-position: 42% 32%;
  }

  /* En vertical la unión es horizontal: la transición neutra baja al
     borde inferior de la banda y entrega la foto en el vino del panel. */
  .auth-hero::after {
    top: auto;
    right: 0;
    bottom: 0;
    left: 0;
    width: auto;
    height: 120px;
    background: linear-gradient(
      to bottom,
      rgba(24, 18, 19, 0) 0%,
      rgba(24, 18, 19, 0.2) 45%,
      rgba(24, 18, 19, 0.45) 78%,
      #341017 100%
    );
  }

  .auth-panel {
    padding: 44px 24px 52px;
  }

  .app-footer--auth {
    position: static;
    text-align: center;
    padding: 0 20px 20px;
  }
}

@media (max-width: 560px) {
  .auth-hero {
    min-height: 236px;
    padding: 26px 22px;
  }

  .auth-panel {
    padding: 32px 18px 40px;
  }

  .auth-card {
    padding: 30px 24px 26px;
  }

  .auth-card::before {
    left: 24px;
    right: 24px;
  }

  .auth-card__brand {
    margin-bottom: 20px;
    padding-bottom: 16px;
  }

  .auth-card__subtitle {
    max-width: 200px;
  }
}

/* =========================================================================
   Header — sesión real (Fase 7A)
   ========================================================================= */

.app-header__logout {
  margin-left: 12px;
}

.btn--compact {
  padding: 7px 14px;
  font-size: 0.8rem;
}

/* =========================================================================
   Sidebar — submenú dinámico (Fase 7D)
   ========================================================================= */

.app-nav__item--group {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  margin: 1px 0;
}

.app-nav__group-header {
  display: flex;
  align-items: center;
  min-width: 0;
  border-left: 3px solid transparent;
  border-radius: var(--radius-sm);
  transition: background 0.16s ease, border-color 0.16s ease;
}

.app-nav__group-header:hover {
  background: rgba(255, 255, 255, 0.09);
}

.app-nav__group-header .app-nav__link:hover {
  background: transparent;
}

.app-nav__group-link {
  flex: 1;
  min-width: 0;
  padding-left: 7px;
}

.app-nav__group-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  min-width: 34px;
  height: 34px;
  margin-right: 2px;
  padding: 0;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: rgba(255, 255, 255, 0.58);
  cursor: pointer;
  transition: background 0.16s ease, color 0.16s ease;
}

.app-nav__group-toggle:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}

.app-nav__group-toggle--full {
  width: 100%;
  height: auto;
  min-height: 38px;
  margin: 0;
  padding: 8px 7px;
  justify-content: flex-start;
  text-align: left;
}

.app-nav__group-toggle--full:hover {
  background: transparent;
}

.app-nav__group-toggle--full > svg {
  width: 18px;
  height: 18px;
}

.app-nav__chevron {
  display: inline-flex;
  margin-left: auto;
  transition: transform 0.2s ease;
}

.app-nav__chevron svg {
  width: 14px;
  height: 14px;
}

.app-nav__item--group.is-expanded .app-nav__chevron {
  transform: rotate(180deg);
}

.app-nav__item--group.app-nav__item--active > .app-nav__group-header {
  background: rgba(255, 255, 255, 0.13);
  border-left-color: #efbdc8;
}

.app-nav__item--group.app-nav__item--active > .app-nav__group-header .app-nav__group-link,
.app-nav__item--group.app-nav__item--active > .app-nav__group-header .app-nav__group-toggle--full {
  color: #fff;
  font-weight: 600;
}

.app-nav__submenu-shell {
  display: grid;
  grid-template-rows: 0fr;
  opacity: 0;
  transition: grid-template-rows 0.2s ease, opacity 0.16s ease;
}

.app-nav__submenu-shell[hidden] {
  display: none;
}

.app-nav__item--group.is-expanded > .app-nav__submenu-shell {
  grid-template-rows: 1fr;
  opacity: 1;
}

.app-sidebar.is-hydrating .app-nav__submenu-shell {
  transition: none;
}

.app-nav__submenu {
  list-style: none;
  min-height: 0;
  overflow: hidden;
  margin: 3px 0 4px 20px;
  padding: 2px 0 2px 8px;
  display: flex;
  flex-direction: column;
  gap: 1px;
  border-left: 1px solid rgba(255, 255, 255, 0.2);
}

.app-nav__submenu .app-nav__link {
  gap: 8px;
  min-height: 31px;
  padding: 5px 8px;
  font-size: 0.82rem;
  color: rgba(255, 255, 255, 0.7);
}

.app-nav__submenu .app-nav__link svg {
  width: 15px;
  height: 15px;
  opacity: 0.7;
}

.app-nav__submenu .app-nav__item--active > .app-nav__link {
  background: rgba(255, 255, 255, 0.13);
  color: #fff;
  font-weight: 600;
  box-shadow: inset 2px 0 0 #efbdc8;
}

@media (prefers-reduced-motion: reduce) {
  .app-sidebar,
  .app-nav__link,
  .app-nav__group-header,
  .app-nav__group-toggle,
  .app-nav__chevron,
  .app-nav__submenu-shell {
    transition: none;
  }
}
