:root {
  --navy: #112F55;
  --navy-dark: #0A2240;
  --gold: #F5B800;
  --gray-50: #F9FAFB;
  --gray-100: #F3F4F6;
  --gray-200: #E5E7EB;
  --gray-500: #6B7280;
  --gray-700: #374151;
  --gray-900: #111827;
  --danger: #DC2626;
  --success: #16A34A;
  --radius: 8px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  color: var(--gray-900);
  background: var(--gray-50);
}

/* ── Layout ───────────────────────────────────────── */
.admin-shell { display: flex; min-height: 100vh; }

.admin-sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: 240px;
  height: 100vh;
  flex-shrink: 0;
  background: var(--navy);
  color: white;
  display: flex;
  flex-direction: column;
  padding: 1.5rem 1rem;
  overflow: hidden; /* el scroll vive adentro, en .admin-nav, no en todo el sidebar */
}

.admin-brand { margin-bottom: 1.5rem; }
.admin-brand strong { font-size: 1.1rem; letter-spacing: .05em; }
.admin-brand small { display: block; color: var(--gold); font-size: .7rem; letter-spacing: .15em; }

.site-switcher { margin-bottom: 1.5rem; }
.site-switcher label { display: block; font-size: .7rem; color: rgba(255,255,255,.6); margin-bottom: .25rem; }
.site-switcher select {
  width: 100%;
  padding: .5rem;
  border-radius: var(--radius);
  border: 1px solid rgba(255,255,255,.2);
  background: var(--navy);
  color: white;
}
.site-switcher select option { background: var(--navy); color: white; }

.admin-nav { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.admin-nav__fixed { display: flex; flex-direction: column; gap: .25rem; flex-shrink: 0; }
.admin-nav__scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: .25rem;
  margin-top: .5rem;
}
.admin-nav__scroll::-webkit-scrollbar { width: 6px; }
.admin-nav__scroll::-webkit-scrollbar-track { background: transparent; }
.admin-nav__scroll::-webkit-scrollbar-thumb { background: rgba(255,255,255,.2); border-radius: 3px; }
.admin-nav a {
  color: rgba(255,255,255,.85);
  text-decoration: none;
  padding: .5rem .75rem;
  border-radius: var(--radius);
  font-size: .9rem;
}
.admin-nav a:hover { background: rgba(255,255,255,.08); }
.admin-nav a.is-active {
  background: rgba(255,255,255,.12);
  color: white;
  font-weight: 600;
  border-left: 3px solid #5B9BD5;
  padding-left: calc(.75rem - 3px);
}
.nav-group-label {
  flex-shrink: 0;
  margin-top: 1rem;
  font-size: .7rem;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: rgba(255,255,255,.4);
  padding: 0 .75rem;
}

/* ── Topbar ───────────────────────────────────────── */
.admin-topbar {
  position: fixed;
  top: 0;
  left: 240px;
  right: 0;
  height: 60px;
  background: white;
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 1.5rem;
  padding: 0 2rem;
  z-index: 40;
}

.topbar-bell {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: var(--radius);
  color: var(--gray-700);
  border: none;
  background: none;
  cursor: pointer;
}
.topbar-bell:hover { background: var(--gray-100); }
.topbar-bell__badge {
  position: absolute;
  top: 2px;
  right: 2px;
  background: #DC2626;
  color: white;
  font-size: .65rem;
  font-weight: 700;
  min-width: 16px;
  height: 16px;
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 3px;
}

.topbar-notifications { position: relative; }
.topbar-notif-panel {
  display: none;
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 280px;
  background: white;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  box-shadow: 0 10px 30px rgba(0,0,0,.12);
  overflow: hidden;
  z-index: 50;
}
.topbar-notif-panel.is-open { display: block; }
.topbar-notif-item {
  display: block;
  padding: .85rem 1rem;
  font-size: .85rem;
  color: #92400E;
  background: #FEF3C7;
  text-decoration: none;
}
.topbar-notif-item:hover { background: #FDE68A; }
.topbar-notif-empty { padding: 1rem; font-size: .85rem; color: var(--gray-500); margin: 0; }

.topbar-user {
  display: flex;
  flex-direction: column;
  line-height: 1.25;
  text-decoration: none;
  color: var(--gray-900);
  padding: .35rem .6rem;
  border-radius: var(--radius);
}
.topbar-user:hover { background: var(--gray-100); }
.topbar-user strong { font-size: .85rem; }
.topbar-user small { color: var(--gray-500); font-size: .72rem; }

.topbar-logout { color: var(--gray-500); font-size: .85rem; text-decoration: none; }
.topbar-logout:hover { color: var(--danger); }

.admin-main { flex: 1; margin-left: 240px; margin-top: 60px; padding: 2rem 2.5rem; max-width: 1000px; }

/* ── Componentes ──────────────────────────────────── */
h1 { font-size: 1.5rem; margin: 0 0 .5rem; }
.muted { color: var(--gray-500); }

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
}

.flash {
  padding: .75rem 1rem;
  border-radius: var(--radius);
  margin-bottom: 1.5rem;
  font-size: .9rem;
}
.flash--success { background: #DCFCE7; color: #166534; }
.flash--error { background: #FEE2E2; color: #991B1B; }
.flash--pendientes {
  display: block;
  background: #FEF3C7;
  color: #92400E;
  border: 1px solid #FCD34D;
  text-decoration: none;
  font-weight: 600;
}
.flash--pendientes:hover { background: #FDE68A; }

.dashboard-alert {
  display: block;
  background: #FEF3C7;
  color: #92400E;
  border: 1px solid #FCD34D;
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  text-decoration: none;
  font-size: .95rem;
  margin-bottom: 1.5rem;
}
.dashboard-alert:hover { background: #FDE68A; }

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1rem;
}
.card-tile {
  display: block;
  background: white;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 1.25rem;
  text-decoration: none;
  color: var(--gray-900);
}
.card-tile:hover { border-color: var(--navy); box-shadow: 0 2px 8px rgba(0,0,0,.06); }
.card-tile strong { display: block; margin-bottom: .25rem; }

.btn-primary, .btn-secondary {
  display: inline-block;
  padding: .6rem 1.1rem;
  border-radius: var(--radius);
  border: none;
  font-size: .9rem;
  cursor: pointer;
  text-decoration: none;
}
.btn-primary { background: var(--navy); color: white; }
.btn-primary:hover { background: var(--navy-dark); }
.btn-secondary { background: var(--gray-100); color: var(--gray-700); }

.admin-table { width: 100%; border-collapse: collapse; background: white; }
.admin-table th, .admin-table td {
  text-align: left;
  padding: .65rem .75rem;
  border-bottom: 1px solid var(--gray-200);
  font-size: .9rem;
}
.admin-table th { color: var(--gray-500); font-weight: 600; font-size: .75rem; text-transform: uppercase; }
.admin-table .actions { vertical-align: middle; }
.admin-table .actions > a,
.admin-table .actions > form { display: inline-block; vertical-align: middle; margin-right: .75rem; }
.admin-table .actions > a:last-child,
.admin-table .actions > form:last-child { margin-right: 0; }
.admin-table .actions a { color: var(--navy); text-decoration: none; }
.link-danger { background: none; border: none; color: var(--danger); cursor: pointer; padding: 0; font-size: .9rem; }

.admin-form { background: white; border: 1px solid var(--gray-200); border-radius: var(--radius); padding: 1.5rem; max-width: 640px; }
.form-field { margin-bottom: 1.1rem; }
.form-field label { display: block; font-size: .85rem; font-weight: 600; margin-bottom: .35rem; }
.form-field input[type="text"],
.form-field input[type="date"],
.form-field input[type="number"],
.form-field input[type="password"],
.form-field input[type="email"],
.form-field input[type="tel"],
.form-field input[type="url"],
.form-field textarea,
.form-field select {
  width: 100%;
  padding: .55rem .7rem;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  font-size: .9rem;
  font-family: inherit;
}
.form-field--inline { max-width: 160px; }
.checkbox-inline { display: flex; align-items: center; gap: .5rem; font-weight: 400 !important; }

/* ── Filtros / tabs / plan de estudios (fase 2) ─────── */
.filter-row { display: flex; gap: .5rem; flex-wrap: wrap; margin-bottom: 1.25rem; }
.filter-chip {
  padding: .4rem .9rem;
  border-radius: 999px;
  border: 1px solid var(--gray-200);
  background: white;
  color: var(--gray-700);
  font-size: .85rem;
  text-decoration: none;
}
.filter-chip.is-active { background: var(--navy); color: white; border-color: var(--navy); }

.tab-links { display: flex; gap: 1.5rem; border-bottom: 1px solid var(--gray-200); margin-bottom: 1.5rem; }
.tab-link {
  padding-bottom: .75rem;
  color: var(--gray-500);
  text-decoration: none;
  font-size: .9rem;
  border-bottom: 2px solid transparent;
}
.tab-link.is-active { color: var(--navy); border-bottom-color: var(--navy); font-weight: 600; }

.modalidades-table input[type="text"] { width: 100%; padding: .4rem .5rem; font-size: .85rem; }

.periodo-card {
  background: white;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: 1rem;
  max-width: 640px;
}
.periodo-card--new { border-style: dashed; }
.periodo-card__header { display: flex; justify-content: space-between; align-items: center; margin-bottom: .75rem; }

.materia-list { list-style: none; padding: 0; margin: 0 0 1rem; }
.materia-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: .4rem 0;
  border-bottom: 1px solid var(--gray-100);
  font-size: .9rem;
}

.inline-add-form { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.inline-add-form input[type="text"],
.inline-add-form input[type="number"] {
  padding: .5rem .6rem;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  font-size: .85rem;
}
.inline-add-form input[type="text"] { flex: 1; min-width: 160px; }

/* ── Selector de íconos ───────────────────────────────── */
.icon-picker__trigger {
  display: flex;
  align-items: center;
  gap: .6rem;
  width: 100%;
  padding: .6rem .8rem;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  background: white;
  cursor: pointer;
  font-size: .9rem;
  text-align: left;
}
.icon-picker__trigger:hover { border-color: var(--navy); }
.icon-picker__preview { display: inline-flex; width: 20px; height: 20px; color: var(--navy); flex-shrink: 0; }
.icon-picker__preview svg { width: 100%; height: 100%; }

.icon-modal__backdrop {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.4);
  z-index: 100;
  align-items: center;
  justify-content: center;
}
.icon-modal__backdrop.is-open { display: flex; }
.icon-modal {
  background: white;
  border-radius: 12px;
  padding: 1.25rem;
  width: 100%;
  max-width: 560px;
  max-height: 70vh;
  display: flex;
  flex-direction: column;
}
.icon-modal input[type="text"] {
  padding: .6rem .8rem;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  margin-bottom: 1rem;
  font-size: .9rem;
}
.icon-modal__grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
  gap: .5rem;
  overflow-y: auto;
}
.icon-modal__item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .35rem;
  padding: .75rem .5rem;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  background: white;
  cursor: pointer;
}
.icon-modal__item:hover { border-color: var(--navy); background: var(--gray-50); }
.icon-modal__item svg { width: 22px; height: 22px; color: var(--navy); }
.icon-modal__item span { font-size: .68rem; color: var(--gray-500); text-align: center; word-break: break-word; }

/* ── Input de archivo dentro de tarjetas (documentos) ──── */
.card-tile { overflow: hidden; }
.card-tile input[type="file"] {
  width: 100%;
  max-width: 100%;
  font-size: .75rem;
  box-sizing: border-box;
}

/* ── Combo (Tipo / Área): input libre + sugerencias con estilo propio ── */
.combo { position: relative; }
.combo__list {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: white;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  box-shadow: 0 8px 20px rgba(0,0,0,.08);
  max-height: 220px;
  overflow-y: auto;
  z-index: 20;
}
.combo__list.is-open { display: block; }
.combo__item {
  padding: .55rem .8rem;
  font-size: .88rem;
  cursor: pointer;
}
.combo__item:hover { background: var(--gray-50); color: var(--navy); }

/* ── Vista previa de imagen actual (ajustes y colecciones) ── */
.current-image {
  display: flex;
  align-items: center;
  gap: .75rem;
  margin-bottom: .5rem;
  padding: .5rem .75rem;
  background: var(--gray-50);
  border-radius: var(--radius);
}
.current-image img { border-radius: 4px; object-fit: cover; }

/* ── Login ────────────────────────────────────────── */
.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--navy);
}
.login-card {
  background: white;
  border-radius: 12px;
  padding: 2rem;
  width: 100%;
  max-width: 360px;
}
.login-brand { text-align: center; margin-bottom: 1.5rem; }
.login-brand strong { display: block; font-size: 1.2rem; color: var(--navy); letter-spacing: .05em; }
.login-brand small { color: var(--gold); font-size: .7rem; letter-spacing: .15em; }
.login-card label { display: block; font-size: .85rem; font-weight: 600; margin: .75rem 0 .35rem; }
.login-card input {
  width: 100%;
  padding: .6rem .75rem;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  font-size: .9rem;
}
.login-card .btn-primary { width: 100%; margin-top: 1.25rem; padding: .7rem; }