:root {
  --navy: #1f2937;
  --navy-2: #111827;
  --panel: #ffffff;
  --line: #d8dee8;
  --soft: #f3f6fb;
  --mint: #bfe7e3;
  --ink-purple: #34245f;
  --lavender: #c5bee9;
  --text: #101827;
  --muted: #5b6b84;
  --primary: #5b45d9;
  --primary-dark: #4634b5;
  --pink: #ff4f9a;
  --success: #12805c;
  --danger: #b42318;
  --radius: 8px;
  font-family: Inter, "Segoe UI", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--text);
  background: var(--soft);
}

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

button,
input,
select {
  font: inherit;
}

.brand-mark {
  width: 76px;
  height: 76px;
  display: block;
  border-radius: 50%;
  object-fit: contain;
}

.login-card .brand-mark {
  width: 92px;
  height: 92px;
}

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 32px;
  background:
    linear-gradient(118deg, var(--navy) 0 42%, transparent 42.1%),
    linear-gradient(118deg, transparent 0 44%, #eef3fb 44.1% 100%);
}

.login-card {
  width: min(560px, 100%);
  padding: 44px 46px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: 0 24px 70px rgba(16, 24, 39, 0.18);
}

.login-card h1 {
  margin: 30px 0 24px;
  font-size: clamp(34px, 4vw, 44px);
  letter-spacing: 0;
}

.login-card p {
  max-width: 430px;
  margin: 0 0 26px;
  color: var(--muted);
  font-size: 19px;
  line-height: 1.45;
}

.form-field {
  display: grid;
  gap: 8px;
  margin-bottom: 18px;
}

.form-field label {
  font-weight: 800;
}

.input,
.select {
  min-height: 50px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 16px;
  color: var(--text);
  background: #fff;
}

.input:focus,
.select:focus {
  outline: 3px solid rgba(91, 69, 217, 0.17);
  border-color: var(--primary);
}

.button {
  display: inline-flex;
  min-height: 50px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 0;
  border-radius: 6px;
  padding: 0 20px;
  color: #fff;
  background: var(--primary);
  font-weight: 800;
  cursor: pointer;
}

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

.button.secondary {
  color: var(--text);
  border: 1px solid var(--line);
  background: #fff;
}

.button.secondary:hover {
  background: #f7f9fc;
}

.login-button {
  width: 100%;
  margin-top: 12px;
  font-size: 20px;
  background: #4f46e5;
}

.google-login-button {
  width: 100%;
  margin-top: 14px;
  color: #1f2937;
  background: #fff;
  border: 1px solid #cbd5e1;
  box-shadow: 0 1px 2px rgba(15, 23, 42, .12);
}
.google-login-button::before { content: "G"; color: #4285f4; font-size: 20px; font-weight: 900; }
.google-login-button:hover { background: #f8fafc; }

.demo-note {
  margin-top: 8px;
  color: var(--muted);
}

.login-error {
  margin-top: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  background: #fdeceb;
  color: #b3261e;
  font-size: 14px;
  text-align: center;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 280px 1fr;
  transition: grid-template-columns 0.25s ease;
}

.sidebar {
  position: sticky;
  top: 0;
  min-width: 0;
  height: 100vh;
  overflow: auto;
  padding: 28px 14px;
  color: #fff;
  background: var(--navy);
  transition: transform 0.25s ease, padding 0.25s ease;
}

.app-shell.sidebar-collapsed { grid-template-columns: 0 minmax(0, 1fr); }
.app-shell.sidebar-collapsed .sidebar {
  transform: translateX(-280px);
  overflow: hidden;
  padding-left: 0;
  padding-right: 0;
  pointer-events: none;
}

.sidebar .brand-mark {
  width: 108px;
  height: 108px;
  margin: 0 auto 30px;
}

.avisos-bell {
  position: absolute;
  top: 16px;
  left: 34px;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 46px;
  height: 46px;
  margin: 0;
  border-radius: 50%;
  background: var(--navy-2);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35);
  font-size: 20px;
  text-decoration: none;
  transition: background 0.15s ease;
}

.avisos-bell:hover {
  background: rgba(255, 255, 255, 0.16);
}

.avisos-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  border-radius: 999px;
  background: #e33e3e;
  color: #fff;
  font-size: 11px;
  font-weight: 900;
  line-height: 18px;
  text-align: center;
  border: 2px solid var(--navy);
}

/* Cuando la campanita va suelta (no dentro del sidebar oscuro), como en
   dashboard.html o avisos-general.html: se deja fija en la esquina con su
   propio fondo oscuro, para que se vea igual de bien sobre un fondo claro. */
body > a.avisos-bell {
  position: fixed;
  top: 66px;
  left: 14px;
  z-index: 500;
  background: var(--navy);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
}

body > a.avisos-bell:hover {
  background: var(--navy-2);
}

.sidebar-label {
  padding: 0 18px 14px;
  color: #b9c2d2;
  font-size: 15px;
  font-weight: 900;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.nav-list {
  display: grid;
  gap: 8px;
}

.nav-item {
  display: block;
  padding: 18px 22px;
  border-radius: 6px;
  font-size: 20px;
}

.nav-item:hover,
.nav-item.active {
  background: #30394c;
}

.nav-back-dashboard {
  display: block;
  margin-top: 18px;
  padding: 14px 22px;
  border-radius: 6px;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  padding-top: 22px;
  font-size: 16px;
  font-weight: 700;
  color: #b9c2d2;
}

.nav-back-dashboard:hover {
  color: #fff;
  background: #30394c;
}

.main {
  min-width: 0;
}

.topbar {
  display: flex;
  min-height: 88px;
  align-items: center;
  justify-content: space-between;
  gap: 22px;
  padding: 0 34px;
  border-bottom: 1px solid var(--line);
  background: #fff;
}

.topbar-title {
  display: flex;
  align-items: center;
  gap: 24px;
  font-size: 21px;
  font-weight: 900;
}

.menu-icon {
  font-size: 34px;
  line-height: 1;
  cursor: pointer;
  border-radius: 8px;
  padding: 4px 6px;
  transition: background 0.15s ease, transform 0.15s ease;
}
.menu-icon:hover, .menu-icon:focus { background: var(--soft); outline: none; transform: scale(1.05); }

.session-text {
  color: var(--muted);
  font-size: 17px;
}

.logout-button {
  display: inline-flex;
  min-height: 42px;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  padding: 0 18px;
  color: #fff;
  background: var(--danger);
  font-size: 16px;
  font-weight: 800;
}

.logout-button:hover {
  background: #8f1d14;
}

.content {
  padding: 34px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 24px;
  margin-bottom: 28px;
}

.stat-card,
.section,
.placeholder {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}

.stat-card {
  min-height: 164px;
  padding: 26px;
}

.stat-card span {
  display: block;
  color: var(--muted);
  font-size: 20px;
}

.stat-card strong {
  display: block;
  margin: 18px 0 14px;
  font-size: 38px;
}

.stat-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.section {
  margin-bottom: 26px;
  overflow: hidden;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 20px 24px;
  border-bottom: 1px solid var(--line);
}

.section-header h2,
.section-header h3 {
  margin: 0;
  font-size: 25px;
}

.header-actions {
  display: flex;
  gap: 10px;
}

.list-toolbar {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) 180px 170px 150px auto;
  gap: 10px;
  align-items: end;
  padding: 18px 18px 8px;
}

.toolbar-field {
  display: grid;
  gap: 6px;
}

.toolbar-field label {
  color: var(--muted);
  font-size: 14px;
}

.toolbar-field.compact {
  min-width: 130px;
}

.form-grid {
  display: grid;
  grid-template-columns: 1.1fr 1fr 0.8fr 0.9fr 0.9fr auto;
  gap: 18px;
  align-items: end;
  padding: 24px;
}

.student-grid {
  display: grid;
  grid-template-columns: 0.7fr 1.2fr 1fr 0.9fr;
  gap: 18px;
  align-items: end;
  padding: 24px;
}

.book-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 18px;
  align-items: end;
  padding: 24px;
}

.library-form {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 18px;
  align-items: end;
  padding: 24px;
}

.library-form .wide {
  grid-column: span 2;
  min-width: 0;
}

@media (max-width: 900px) {
  .library-form { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 560px) {
  .library-form { grid-template-columns: 1fr; }
  .library-form .wide { grid-column: span 1; }
}

.generated-id {
  color: var(--ink-purple);
  background: #f4f0ff;
  font-weight: 900;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.attendance-grid {
  display: grid;
  grid-template-columns: 1.4fr 0.9fr 1fr auto;
  gap: 18px;
  align-items: end;
  padding: 24px;
}

.modalidad-grid {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 18px;
  align-items: end;
  padding: 24px;
}

.modalidad-grid.modalidad-grid-level { grid-template-columns: minmax(220px, 1fr) 180px auto; }

.sub-section-header {
  margin-top: 10px;
  border-top: 1px solid var(--line);
}

.nested-card {
  background: var(--soft);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  margin-top: 24px;
}

.nested-card .section-header {
  margin-bottom: 4px;
}

.nested-card .section-subtitle {
  margin-bottom: 16px;
}

.meta-edit-panel {
  max-width: 360px;
  margin-top: 14px;
  margin-bottom: 18px;
}

.meta-edit-panel .form-field {
  margin-bottom: 14px;
}

.meta-edit-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.meta-edit-actions .button {
  flex: 0 0 auto;
  white-space: nowrap;
}

.modality-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  padding: 20px 24px 8px;
}

.modality-buttons .button.active,
.level-buttons .mini-button.active {
  background: var(--navy);
  color: #fff;
}

.modalidades-header {
  align-items: flex-start;
}

.level-buttons {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.mini-button {
  display: inline-flex;
  min-height: 34px;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 12px;
  background: #fff;
  color: var(--text);
  font-size: 13px;
  font-weight: 900;
}

.library-section {
  border: 0;
  background: transparent;
}

.library-section .section-header,
.library-section .book-grid,
.library-section .table-wrap,
.library-section .empty-state {
  border: 1px solid var(--line);
  background: #fff;
}

.library-section .section-header {
  border-radius: var(--radius) var(--radius) 0 0;
}

.library-section .book-grid {
  border-top: 0;
  border-bottom: 0;
}

.library-section .table-wrap {
  border-top: 0;
  border-radius: 0 0 var(--radius) var(--radius);
}

.library-page {
  display: grid;
  gap: 26px;
}

.library-hero {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) auto;
  gap: 24px;
  align-items: center;
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: #fff;
  background: linear-gradient(135deg, var(--navy), #35256b);
}

.library-hero span {
  color: var(--mint);
  font-weight: 900;
  text-transform: uppercase;
}

.library-hero h1 {
  margin: 8px 0 0;
  font-size: 38px;
  letter-spacing: 0;
}

.hero-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(120px, 1fr));
  gap: 12px;
}

.hero-metrics article {
  padding: 16px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.08);
}

.hero-metrics strong {
  display: block;
  margin-top: 8px;
  font-size: 30px;
}

.library-toolbar {
  grid-template-columns: minmax(260px, 1fr) auto;
  padding-top: 0;
  padding-bottom: 18px;
}

.quick-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(130px, 1fr));
  gap: 14px;
  padding: 24px;
}

.quick-card {
  min-height: 92px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 16px;
  color: var(--text);
  background: #fbfcff;
  cursor: pointer;
  text-align: left;
}

.quick-card:hover {
  border-color: var(--primary);
}

.quick-card strong,
.quick-card span {
  display: block;
}

.quick-card span {
  margin-top: 10px;
  color: var(--muted);
}

.section-subtitle {
  margin: 6px 0 0;
  color: var(--muted);
}

/* Las descripciones que van directamente dentro de una tarjeta necesitan el
   mismo margen lateral que sus formularios; así no quedan pegadas al borde. */
.section > .section-subtitle {
  margin: 0;
  padding: 16px 24px 4px;
  line-height: 1.5;
}

.cutoff-form {
  display: flex;
  align-items: end;
  gap: 16px;
  padding: 20px 24px 24px;
}

.cutoff-form .form-field { min-width: min(260px, 100%); }

.reporte-grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.reporte-panel { overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; }
.reporte-panel-header { padding: 16px 20px; color: #fff; background: var(--navy); }
.reporte-panel-header h3 { margin: 0; }
.reporte-panel-body { padding: 18px; }
.reporte-range-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.reporte-shortcuts { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0 18px; }
.report-band { margin: 18px 0 10px; padding: 8px 10px; border-radius: 8px; color: var(--navy-2); background: var(--soft); font-weight: 800; }
.reporte-panel .money-breakdown-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.reporte-panel .money-breakdown-card { padding: 13px; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.reporte-panel .money-breakdown-card span { display: block; color: var(--muted); font-size: 13px; }
.reporte-panel .money-breakdown-card strong { display: block; margin-top: 5px; color: var(--navy-2); font-size: 20px; }
.reporte-panel .saldo-banner { margin-top: 16px; padding: 13px; border: 1px solid #c7d2fe; border-radius: 10px; color: #312e81; background: #eef2ff; font-weight: 800; line-height: 1.4; }

.month-comparison { display: grid; grid-template-columns: 1.4fr repeat(3, minmax(150px, 1fr)); gap: 14px; align-items: stretch; margin: 0 0 24px; padding: 18px; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; }
.month-comparison h3 { margin: 0 0 6px; color: var(--navy-2); font-size: 19px; }
.month-comparison p { margin: 0; color: var(--muted); font-size: 14px; line-height: 1.4; }
.month-comparison article { display: flex; flex-direction: column; justify-content: center; padding: 14px; border-radius: 10px; background: var(--soft); }
.month-comparison article span, .month-comparison article small { color: var(--muted); font-size: 13px; }
.month-comparison article strong { margin: 5px 0; color: var(--navy-2); font-size: 22px; }
.month-comparison-diff { background: #f3f0ff !important; }
.month-comparison strong.positive { color: #157347; }
.month-comparison strong.negative { color: #b42318; }

.monthly-overview-chart { display: grid; gap: 12px; max-width: 760px; }
.monthly-overview-chart > div { display: grid; grid-template-columns: 130px minmax(100px, 1fr) 104px; align-items: center; gap: 12px; }
.monthly-overview-chart span { color: var(--muted); font-size: 14px; }
.monthly-overview-chart i { display: block; height: 22px; overflow: hidden; border-radius: 6px; background: #eef1f8; }
.monthly-overview-chart b { display: block; min-width: 5px; height: 100%; border-radius: inherit; }
.monthly-overview-chart strong { text-align: right; color: var(--navy-2); }
.payment-summary-section { margin-top: 22px; }
.payment-summary-count { margin: 0; padding: 14px 24px 20px; color: var(--muted); }

/* Filtros y totales del reporte de egresos. */
.range-controls { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; padding: 20px 24px; border-bottom: 1px solid var(--line); }
.range-shortcuts { display: flex; flex-wrap: wrap; gap: 8px; }
.range-shortcuts .mini-button { min-height: 40px; padding: 0 13px; }
.money-breakdown-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; padding: 20px 24px; }
.money-breakdown-card { padding: 16px; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.money-breakdown-card span { display: block; color: var(--muted); font-size: 14px; }
.money-breakdown-card strong { display: block; margin-top: 7px; color: var(--navy-2); font-size: 24px; }
.saldo-banner { margin: 0 24px 24px; padding: 14px 16px; border: 1px solid #c7d2fe; border-radius: 10px; color: #312e81; background: #eef2ff; font-weight: 800; }

@media (max-width: 900px) { .reporte-grid-2 { grid-template-columns: 1fr; } }
@media (max-width: 900px) { .month-comparison { grid-template-columns: repeat(2, minmax(0, 1fr)); } .month-comparison > div { grid-column: 1 / -1; } }
@media (max-width: 900px) { .range-controls { grid-template-columns: 1fr; } .money-breakdown-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

@media (max-width: 640px) {
  .cutoff-form { align-items: stretch; flex-direction: column; }
  .reporte-range-row { grid-template-columns: 1fr; }
  .reporte-panel .money-breakdown-grid { grid-template-columns: 1fr; }
  .month-comparison { grid-template-columns: 1fr; }
  .money-breakdown-grid { grid-template-columns: 1fr; }
}

.report-header {
  align-items: flex-start;
}

.report-month-label {
  color: var(--primary);
  font-size: 18px;
  text-transform: capitalize;
}

.report-controls {
  display: grid;
  gap: 18px;
  padding: 22px 24px;
  border-bottom: 1px solid var(--line);
}

.report-control-block {
  display: grid;
  gap: 10px;
}

.report-control-block > span {
  color: var(--muted);
  font-size: 14px;
  font-weight: 900;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.button-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.button-strip .mini-button {
  min-height: 42px;
  padding: 0 16px;
  cursor: pointer;
  text-transform: capitalize;
}

.month-year-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.month-year-picker .select {
  min-height: 42px;
  min-width: 150px;
  text-transform: capitalize;
}

.report-summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  padding: 22px 24px;
}

.report-summary-card {
  min-height: 112px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbfcff;
}

.report-summary-card span {
  display: block;
  color: var(--muted);
  font-weight: 800;
}

.report-summary-card strong {
  display: block;
  margin-top: 12px;
  font-size: 28px;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  white-space: nowrap;
}

th {
  color: var(--muted);
  background: #fbfcff;
  font-size: 14px;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.amount {
  font-weight: 900;
}

.month-color-1  { background: #eaf1ff; }
.month-color-2  { background: #f2ecfb; }
.month-color-3  { background: #fdeef3; }
.month-color-4  { background: #fdeee5; }
.month-color-5  { background: #fef6e0; }
.month-color-6  { background: #f2f9e3; }
.month-color-7  { background: #eafaf1; }
.month-color-8  { background: #e6f8f5; }
.month-color-9  { background: #e6f4fb; }
.month-color-10 { background: #eceafb; }
.month-color-11 { background: #faeaf6; }
.month-color-12 { background: #f0f0f2; }

.month-color-1 td,
.month-color-2 td,
.month-color-3 td,
.month-color-4 td,
.month-color-5 td,
.month-color-6 td,
.month-color-7 td,
.month-color-8 td,
.month-color-9 td,
.month-color-10 td,
.month-color-11 td,
.month-color-12 td {
  border-bottom-color: rgba(15, 23, 42, 0.06);
}

.empty-state {
  padding: 34px 24px;
  color: var(--muted);
  text-align: center;
}

.row-actions button {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--danger);
  background: #fff;
  cursor: pointer;
  font-weight: 800;
}

.row-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  min-width: 270px;
}

.row-actions button:first-child {
  color: var(--primary);
}

.row-actions button:hover {
  background: #f7f9fc;
}

.row-actions button.action-edit {
  border-color: #c9bcff;
  color: #fff;
  background: #5b45d9;
}

.row-actions .action-edit:hover {
  background: #4631bb;
}

.row-actions button.action-delete {
  border-color: #f3b8b4;
  color: #fff;
  background: #c62820;
}

.row-actions .action-delete:hover {
  background: #a91e18;
}

.modalidad-delete-btn {
  min-width: 28px;
  min-height: 28px;
  border: 1px solid #f3b8b4;
  border-radius: 6px;
  color: #fff;
  background: #c62820;
  font-size: 19px;
  font-weight: 800;
  line-height: 1;
  cursor: pointer;
}
.modalidad-delete-btn:hover { background: #a91e18; }

.status-pill {
  display: inline-flex;
  min-height: 30px;
  align-items: center;
  border-radius: 999px;
  padding: 0 10px;
  color: var(--text);
  background: #eef2f7;
  font-size: 13px;
  font-weight: 900;
}

.status-activo {
  color: #116149;
  background: #dff7ed;
}

.status-graduado {
  color: #2d3c97;
  background: #e6e9ff;
}

.status-baja {
  color: #8f1d14;
  background: #ffe2df;
}

.loan-ok td {
  background: #f6fff9;
}

.loan-soon td {
  background: #fff7d6;
}

.loan-overdue td {
  background: #ffe9e6;
}

.placeholder {
  padding: 32px;
}

.placeholder h2 {
  margin: 0 0 12px;
}

.placeholder p {
  margin: 0;
  color: var(--muted);
}

.attendance-sheet {
  padding: 36px;
  border: 10px solid var(--lavender);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 18px 45px rgba(52, 36, 95, 0.12);
}

.attendance-title {
  display: flex;
  align-items: baseline;
  gap: 18px;
  margin-bottom: 26px;
  color: var(--ink-purple);
  text-transform: uppercase;
}

.attendance-title span {
  color: var(--mint);
  font-size: clamp(42px, 8vw, 86px);
  font-weight: 900;
  letter-spacing: 0;
}

.attendance-title strong {
  font-size: clamp(28px, 4vw, 46px);
  letter-spacing: 0;
}

.sheet-fields {
  display: grid;
  grid-template-columns: repeat(3, minmax(180px, 1fr));
  gap: 22px;
  margin-bottom: 22px;
}

.sheet-field {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  min-height: 58px;
  border: 4px solid var(--ink-purple);
  border-radius: 2px;
  background: #fff;
}

.sheet-field label {
  padding: 0 12px;
  color: var(--ink-purple);
  font-size: 19px;
  font-weight: 900;
  text-transform: uppercase;
}

.sheet-field input,
.sheet-field select {
  min-width: 0;
  height: 100%;
  border: 0;
  padding: 0 12px;
  color: var(--text);
  background: #fff;
  font-weight: 800;
}

.sheet-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-bottom: 18px;
}

.sheet-wrap {
  border: 4px solid var(--ink-purple);
  border-radius: 2px;
}

.sheet-table th,
.sheet-table td {
  height: 42px;
  border: 3px solid var(--ink-purple);
  padding: 0;
  text-align: center;
}

.sheet-table th {
  color: var(--ink-purple);
  background: #eee9ff;
  font-size: 18px;
}

.sheet-table .sheet-number {
  width: 48px;
  min-width: 48px;
  color: var(--ink-purple);
  background: #f4f0ff;
  font-weight: 900;
}

.sheet-table .sheet-name {
  width: 290px;
  min-width: 290px;
  padding: 0 14px;
  text-align: left;
  font-weight: 900;
}

.sheet-table th.sheet-name {
  text-align: center;
}

.sheet-table .sheet-day {
  width: 42px;
  min-width: 42px;
}

.sheet-cell button {
  width: 100%;
  height: 100%;
  border: 0;
  color: var(--ink-purple);
  background: #fff;
  font-weight: 900;
  cursor: pointer;
}

.sheet-cell button:hover {
  background: #f4f0ff;
}

@media (max-width: 1100px) {
  .app-shell {
    grid-template-columns: 220px 1fr;
  }

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

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

  .student-grid,
  .attendance-grid,
  .modalidad-grid,
  .book-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .form-grid .button,
  .student-grid .button,
  .attendance-grid .button,
  .modalidad-grid .button,
  .book-grid .button {
    grid-column: 1 / -1;
  }

  .list-toolbar {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .quick-grid {
    grid-template-columns: repeat(3, minmax(130px, 1fr));
  }

  .report-summary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .login-page {
    display: block;
    padding: 22px;
    background: var(--navy);
  }

  .login-card {
    margin: 28px auto;
    padding: 30px 24px;
  }

  .app-shell {
    display: block;
  }

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 700;
    width: 280px;
    height: 100vh;
    padding: 18px 14px;
    box-shadow: 8px 0 22px rgba(15, 23, 42, 0.28);
  }

  .app-shell.sidebar-collapsed .sidebar {
    transform: translateX(-105%);
    padding: 18px 14px;
    overflow: auto;
  }

  .sidebar .brand-mark {
    margin-bottom: 18px;
  }

  .nav-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .nav-item {
    padding: 14px;
    font-size: 16px;
  }

  .topbar {
    min-height: auto;
    padding: 20px;
    align-items: flex-start;
    flex-direction: column;
  }

  .content {
    padding: 20px;
  }

  .stats-grid,
  .form-grid,
  .student-grid,
  .attendance-grid,
  .modalidad-grid,
  .book-grid,
  .quick-grid {
    grid-template-columns: 1fr;
  }

  .section-header,
  .header-actions,
  .list-toolbar {
    align-items: stretch;
    flex-direction: column;
    grid-template-columns: 1fr;
  }

  .attendance-sheet {
    padding: 16px;
    border-width: 6px;
  }

  .attendance-title {
    display: block;
  }

  .sheet-fields {
    grid-template-columns: 1fr;
  }

  .sheet-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .modality-buttons,
  .level-buttons {
    flex-direction: column;
  }

  .report-summary-grid {
    grid-template-columns: 1fr;
  }

  .button-strip {
    display: grid;
    grid-template-columns: 1fr;
  }

  .month-year-picker {
    display: grid;
    grid-template-columns: 1fr;
  }
}

/* ========== LIBROS: TABS ========== */
.lib-tabs {
  display: flex;
  gap: 0;
  margin-bottom: 0;
  border-bottom: 2px solid var(--line);
}

.lib-tab {
  padding: 14px 32px;
  border: 0;
  border-bottom: 3px solid transparent;
  margin-bottom: -2px;
  background: transparent;
  color: var(--muted);
  font-size: 17px;
  font-weight: 800;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}

.lib-tab:hover {
  color: var(--text);
  background: #f7f9fc;
}

.lib-tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  background: #fff;
}

.lib-panel {
  padding-top: 24px;
}

/* ========== LIBROS: BUSCADOR GLOBAL ========== */
.library-search-bar {
  margin-bottom: 0 !important;
}

.library-search-inner {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 18px 24px;
}

.search-icon {
  font-size: 20px;
}

.library-search-inner .input {
  flex: 1;
  font-size: 16px;
}

.global-search-results {
  border-top: 1px solid var(--line);
  padding: 12px 24px 18px;
}

.global-search-results h4 {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.global-search-results table {
  font-size: 14px;
}

/* ========== LIBROS: LOAN SUMMARY ========== */
.loan-summary-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(180px, 260px));
  gap: 18px;
  justify-content: start;
  margin-bottom: 24px;
}

.loan-summary-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 22px 16px;
  border-radius: var(--radius);
  border: 2px solid transparent;
  text-align: center;
}

.loan-summary-card strong {
  font-size: 42px;
  font-weight: 900;
  line-height: 1;
}

.loan-summary-card span {
  font-size: 14px;
  font-weight: 700;
}

.loan-summary-ok {
  background: #f0fdf6;
  border-color: #86efac;
  color: #15803d;
}

.loan-summary-soon {
  background: #fffbeb;
  border-color: #fcd34d;
  color: #92400e;
}

.loan-summary-overdue {
  background: #fff1f0;
  border-color: #fca5a5;
  color: #991b1b;
}

.loan-returned {
  background: #f0fdf4;
}

.loan-returned-pill {
  background: #dcfce7;
  color: #166534;
}

.loan-lost {
  background: #fff7ed;
}

.loan-lost-pill {
  background: #ffedd5;
  color: #9a3412;
}

.row-actions button.action-return {
  border-color: #86efac;
  color: #166534;
  background: #f0fdf4;
}

.row-actions button.action-lost {
  border-color: #fdba74;
  color: #9a3412;
  background: #fff7ed;
}

.loan-delay-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 210px));
  gap: 18px;
  align-items: stretch;
  justify-content: start;
  margin: -8px 0 24px;
}

.loan-delay-summary > div,
.loan-delay-rate-form,
.loan-delay-summary > p {
  margin: 0;
  padding: 14px 16px;
  border: 1px solid #fecaca;
  border-radius: 8px;
  background: #fff7ed;
}

.loan-delay-rate-form {
  min-width: 0;
  width: auto;
  justify-self: stretch;
  box-sizing: border-box;
}

.loan-delay-summary span {
  display: block;
  color: #9a3412;
  font-size: 13px;
  font-weight: 800;
}

.loan-delay-summary strong {
  display: block;
  margin-top: 5px;
  color: #9a3412;
  font-size: 22px;
}

.loan-delay-rate-form label {
  display: block;
  color: #9a3412;
  font-size: 13px;
  font-weight: 800;
}

.loan-delay-rate-form > div {
  display: flex;
  gap: 8px;
  margin-top: 7px;
}

.loan-delay-rate-form .input {
  width: 78px;
  flex: 0 0 78px;
  min-width: 0;
  padding: 8px 10px;
}

.loan-delay-rate-form .button {
  min-height: 38px;
  padding: 0 12px;
  white-space: nowrap;
}

@media (max-width: 900px) {
  .loan-summary-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .loan-delay-summary {
    grid-template-columns: repeat(4, minmax(135px, 180px));
    gap: 14px;
  }
}

@media (max-width: 560px) {
  .loan-summary-grid { grid-template-columns: 1fr; }
  .loan-delay-summary { grid-template-columns: 1fr; }
}

.loan-delay-summary > p {
  grid-column: auto;
  display: flex;
  align-items: center;
  border-color: #fed7aa;
  color: #9a3412;
  font-size: 13px;
  line-height: 1.45;
}

/* Préstamos recientes section visual hint */
.loan-recent-section {
  border-left: 4px solid var(--primary);
}

.badge-muted {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  background: #eef2f7;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  margin-left: 8px;
}

/* Status pills for loans with color coding */
.loan-ok td {
  background: #f0fdf6;
}

.loan-soon td {
  background: #fffbeb;
}

.loan-overdue td {
  background: #fff1f0;
}

.status-pill.loan-ok-pill {
  color: #15803d;
  background: #dcfce7;
}

.status-pill.loan-soon-pill {
  color: #92400e;
  background: #fef3c7;
}

.status-pill.loan-overdue-pill {
  color: #991b1b;
  background: #fee2e2;
}

.status-pill.justificado-pill {
  color: #1e40af;
  background: #dbeafe;
}

.observaciones-cell {
  max-width: 220px;
}

.obs-latest {
  display: inline-block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  vertical-align: middle;
}

.obs-count-badge {
  margin-left: 6px;
}

.checkbox-field {
  align-self: end;
}

.checkbox-field label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
}

.checkbox-field input[type="checkbox"] {
  width: 18px;
  height: 18px;
}

.practica-tag {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 13px;
  white-space: nowrap;
}

.tag-color-0 { background: #e0e7ff; color: #3730a3; }
.tag-color-1 { background: #dcfce7; color: #166534; }
.tag-color-2 { background: #fef3c7; color: #92400e; }
.tag-color-3 { background: #fce7f3; color: #9d174d; }
.tag-color-4 { background: #e0f2fe; color: #075985; }
.tag-color-5 { background: #fee2e2; color: #991b1b; }
.tag-color-6 { background: #ede9fe; color: #5b21b6; }
.tag-color-7 { background: #fff7ed; color: #9a3412; }

.obs-tipo-badge {
  margin-top: 6px;
}

/* ========== ASISTENCIA: EXCEL STYLE ========== */
.excel-sheet {
  padding: 0 !important;
  border: 0 !important;
  background: transparent !important;
  overflow: visible !important;
}

.excel-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 14px 18px;
  border: 2px solid #107c41;
  border-bottom: 1px solid #107c41;
  border-radius: 8px 8px 0 0;
  background: #107c41;
  color: #fff;
  flex-wrap: wrap;
}

.excel-toolbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.excel-logo {
  font-size: 26px;
  line-height: 1;
}

.excel-title {
  font-size: 18px;
  font-weight: 900;
  letter-spacing: 0.01em;
}

.excel-controls {
  display: flex;
  align-items: flex-end;
  gap: 14px;
  flex-wrap: wrap;
}

.excel-field {
  display: grid;
  gap: 4px;
}

.excel-field label {
  color: rgba(255,255,255,0.8);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.excel-select,
.excel-date-input {
  min-height: 38px;
  border: 1px solid rgba(255,255,255,0.3);
  border-radius: 4px;
  padding: 0 12px;
  color: #fff;
  background: rgba(255,255,255,0.15);
  font: inherit;
  font-weight: 700;
}

.excel-select option {
  color: #000;
  background: #fff;
}

.excel-select:focus,
.excel-date-input:focus {
  outline: 2px solid rgba(255,255,255,0.6);
  background: rgba(255,255,255,0.25);
}

.excel-formula-bar {
  display: flex;
  align-items: center;
  height: 36px;
  border: 1px solid #c7c7c7;
  border-top: 0;
  background: #fff;
  padding: 0 10px;
  gap: 12px;
}

.cell-ref {
  min-width: 52px;
  padding: 2px 8px;
  border: 1px solid #c7c7c7;
  border-radius: 2px;
  color: #107c41;
  background: #f0f0f0;
  font-size: 13px;
  font-weight: 900;
  text-align: center;
}

.formula-sep {
  color: #107c41;
  font-size: 15px;
  font-weight: 900;
  padding: 0 6px;
  border-left: 1px solid #c7c7c7;
  border-right: 1px solid #c7c7c7;
}

.formula-val {
  color: #444;
  font-size: 14px;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.excel-grid-wrap {
  position: relative;
  border: 1px solid #c7c7c7;
  border-top: 0;
  overflow: hidden;
  background: #fff;
}

.excel-corner {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 3;
  width: 48px;
  height: 26px;
  border-right: 2px solid #107c41;
  border-bottom: 2px solid #107c41;
  background: #e2efda;
  color: #107c41;
  font-size: 12px;
  font-weight: 900;
  display: flex;
  align-items: center;
  justify-content: center;
}

.excel-table-scroll {
  overflow-x: auto;
  overflow-y: auto;
  max-height: 560px;
}

.excel-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.excel-table thead tr th {
  position: sticky;
  top: 0;
  z-index: 2;
  height: 26px;
  padding: 0 4px;
  border: 1px solid #c7c7c7;
  border-right-color: #107c41;
  background: #e2efda;
  color: #107c41;
  font-size: 12px;
  font-weight: 900;
  text-align: center;
  white-space: nowrap;
  text-transform: none;
  letter-spacing: 0;
}

.excel-table td {
  height: 28px;
  padding: 0;
  border: 1px solid #d4d4d4;
  border-right-color: #c7c7c7;
  text-align: center;
  white-space: nowrap;
}

.excel-table tr:nth-child(even) td {
  background: #f9fef9;
}

.excel-table tr:hover td {
  background: #e8f5e9;
}

/* Row number column */
.excel-table .ex-row-num {
  width: 48px;
  min-width: 48px;
  position: sticky;
  left: 0;
  z-index: 1;
  background: #e2efda;
  color: #107c41;
  font-weight: 900;
  font-size: 12px;
  border-right: 2px solid #107c41 !important;
  text-align: center;
}

.excel-table thead .ex-row-num {
  z-index: 3;
  left: 0;
}

/* Name column */
.excel-table .ex-name {
  width: 260px;
  min-width: 180px;
  position: sticky;
  left: 48px;
  z-index: 1;
  background: #fff;
  border-right: 2px solid #107c41 !important;
  padding: 0 10px;
  text-align: left;
  font-weight: 700;
  font-size: 13px;
}

.excel-table thead .ex-name {
  z-index: 3;
  background: #e2efda;
  text-align: center;
}

.excel-table tr:nth-child(even) .ex-name {
  background: #f9fef9;
}

.excel-table tr:hover .ex-name {
  background: #e8f5e9;
}

/* Day cell */
.excel-table .ex-day {
  width: 36px;
  min-width: 36px;
}

/* Cell button */
.excel-cell-btn {
  display: flex;
  width: 100%;
  height: 28px;
  align-items: center;
  justify-content: center;
  border: 0;
  background: transparent;
  font-size: 13px;
  font-weight: 900;
  cursor: pointer;
  transition: background 0.1s;
}

.excel-cell-btn:hover {
  background: #c8e6c9;
}

.excel-cell-btn.mark-present {
  color: #107c41;
  background: #e8f5e9;
}

.excel-cell-btn.mark-absent {
  color: #b42318;
  background: #ffebee;
}

.excel-cell-btn.mark-justified {
  color: #b06b00;
  background: #fff3e0;
}

.excel-cell-btn.mark-tarde {
  color: #8a5a00;
  background: #fff0c2;
}

/* Encabezado de columna con fecha real + botón para eliminarla */
.excel-table .ex-day {
  width: 46px;
  min-width: 46px;
}

.excel-table .ex-day-disabled {
  background: #f0f0f0;
  color: #b7b7b7;
  font-size: 11px;
}

.excel-table tr:nth-child(even) .ex-day-disabled {
  background: #ececec;
}

.excel-table thead .ex-day {
  position: relative;
  padding-top: 14px;
}

.ex-day-date {
  display: block;
  font-size: 12px;
}

.ex-day-weekday {
  display: block;
  font-size: 9px;
  font-weight: 700;
  color: #5a8f74;
  text-transform: uppercase;
}

.excel-col-del {
  position: absolute;
  top: 1px;
  right: 2px;
  width: 14px;
  height: 14px;
  line-height: 12px;
  padding: 0;
  border: 0;
  border-radius: 3px;
  background: transparent;
  color: #b42318;
  font-size: 11px;
  font-weight: 900;
  cursor: pointer;
}

.excel-col-del:hover {
  background: #ffcdd2;
}

/* Columnas resumen (Asistencias / Faltas / Justificadas / %) */
.excel-table .ex-summary {
  width: 40px;
  min-width: 40px;
  font-size: 12px;
  font-weight: 700;
  color: #444;
  background: #f4f9f4;
}

.excel-table thead .ex-summary {
  background: #d6ecd0;
}

.excel-table .ex-pct {
  font-weight: 900;
}

.excel-table .ex-pct.pct-ok {
  color: #107c41;
}

.excel-table .ex-pct.pct-warn {
  color: #b06b00;
}

.excel-table .ex-pct.pct-bad {
  color: #b42318;
}

.excel-hint {
  margin: 6px 0 0;
  padding: 8px 12px;
  border-radius: 6px;
  background: #eef7f0;
  color: #366049;
  font-size: 12.5px;
}

.scan-banner {
  margin-top: 12px;
  padding: 14px 18px;
  border-radius: 8px;
  font-weight: 900;
  font-size: 16px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.scan-banner .scan-banner-name {
  font-size: 13px;
  font-weight: 700;
  opacity: 0.85;
}

.scan-banner-green {
  background: #e6f7ec;
  color: #0f6b34;
  border: 2px solid #34a853;
}

.scan-banner-orange {
  background: #fff4e2;
  color: #9a5b00;
  border: 2px solid #f5a623;
}

.scan-banner-red {
  background: #fde8e7;
  color: #a30f11;
  border: 2px solid #e33e3e;
}

.scan-banner-gray {
  background: #f1f1f1;
  color: #555;
  border: 2px solid #bbb;
}

.back-to-dashboard-btn {
  position: fixed;
  bottom: 18px;
  right: 18px;
  z-index: 500;
  background: #1f5e3d;
  color: #fff;
  font-weight: 700;
  font-size: 13px;
  padding: 10px 16px;
  border-radius: 999px;
  text-decoration: none;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.22);
}

.back-to-dashboard-btn:hover {
  background: #164a30;
}

/* Código de barras en la lista de alumnos */
.row-barcode-cell {
  display: flex;
  align-items: center;
  gap: 6px;
}

.row-barcode-cell svg {
  height: 34px;
  max-width: 150px;
}

.row-print-btn {
  border: 1px solid var(--border-color, #d8d8d8);
  background: #fff;
  border-radius: 6px;
  padding: 3px 6px;
  cursor: pointer;
  font-size: 13px;
  line-height: 1;
}

.row-print-btn:hover {
  background: #f0f0f0;
}

/* Área de impresión de credenciales: oculta en pantalla, visible solo al imprimir */
.print-only {
  display: none;
}

.credencial-card {
  width: 320px;
  border: 2px solid #1f5e3d;
  border-radius: 12px;
  padding: 16px 18px;
  margin: 0 0 14px 0;
  font-family: Arial, Helvetica, sans-serif;
  page-break-inside: avoid;
  break-inside: avoid;
}

.credencial-card h4 {
  margin: 0 0 2px;
  font-size: 16px;
  color: #1f5e3d;
}

.credencial-card p {
  margin: 0 0 10px;
  font-size: 12px;
  color: #444;
}

.credencial-card .credencial-id {
  font-weight: 900;
  font-size: 14px;
  letter-spacing: 0.05em;
  margin-bottom: 6px;
}

.credencial-card svg {
  width: 100%;
  height: auto;
}

@media print {
  body * {
    visibility: hidden;
  }
  .print-only, .print-only * {
    visibility: visible;
  }
  .print-only {
    display: flex !important;
    flex-wrap: wrap;
    gap: 14px;
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
  }
}

.excel-statusbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 28px;
  padding: 0 16px;
  border: 1px solid #c7c7c7;
  border-top: 0;
  border-radius: 0 0 6px 6px;
  background: #f3f3f3;
  color: #555;
  font-size: 12px;
}

.excel-status-right {
  display: flex;
  gap: 12px;
  color: #107c41;
  font-weight: 700;
}

@media (max-width: 1100px) {
  .loan-summary-grid {
    grid-template-columns: repeat(3, 1fr);
  }
  .excel-toolbar {
    flex-direction: column;
    align-items: flex-start;
  }
}

@media (max-width: 760px) {
  .loan-summary-grid {
    grid-template-columns: 1fr;
  }
  .excel-controls {
    flex-direction: column;
    align-items: stretch;
  }
  .lib-tab {
    padding: 12px 18px;
    font-size: 15px;
  }
}

/* ========== DUAL SEARCH GRID ========== */
.dual-search-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 0;
}

.dual-search-grid[hidden] {
  display: none;
}

.dual-search-grid .library-search-bar {
  margin-bottom: 0 !important;
}

@media (max-width: 760px) {
  .dual-search-grid {
    grid-template-columns: 1fr;
  }
}

/* ========== TARJETAS DE AVISOS (admin/secretaría/maestros/general) ========== */
.avisos-list {
  display: grid;
  gap: 14px;
}

.aviso-card {
  display: grid;
  gap: 10px;
  padding: 16px 18px;
  border-radius: var(--radius);
  background: #fff;
  border: 1px solid var(--line);
  border-left: 5px solid var(--muted);
  box-shadow: 0 1px 3px rgba(16, 24, 39, 0.06);
}

.aviso-card.apagado {
  opacity: 0.55;
}

.aviso-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.aviso-card-title {
  font-weight: 700;
  font-size: 15.5px;
  color: var(--text);
}

.aviso-card-message {
  color: var(--muted);
  font-size: 14.5px;
  line-height: 1.45;
}

.aviso-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  font-size: 13px;
  color: var(--muted);
}

.aviso-card-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.aviso-pill {
  flex: none;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 700;
  white-space: nowrap;
  background: #e5e7eb;
  color: #374151;
}

.aviso-pill.info {
  background: #dbeafe;
  color: #1d4ed8;
}

.aviso-pill.advertencia {
  background: #fef3c7;
  color: #92400e;
}

.aviso-pill.urgente {
  background: #fee2e2;
  color: #b42318;
}

.aviso-pill.inactivo {
  background: #e5e7eb;
  color: #6b7280;
}

.aviso-card:has(.aviso-pill.urgente) {
  border-left-color: var(--danger);
}

.aviso-card:has(.aviso-pill.advertencia) {
  border-left-color: #b45309;
}

.aviso-card:has(.aviso-pill.info) {
  border-left-color: #1d4ed8;
}

/* ========== PÁGINA "PANEL PRINCIPAL" (dashboard.html) ========== */
.admin-hub-page {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 100vh;
  padding: 70px 24px 60px;
  text-align: center;
  background: var(--soft);
}

.admin-hub-logout {
  position: fixed;
  top: 66px;
  right: 18px;
  z-index: 50;
}

.admin-hub-brand {
  width: 150px;
  height: 150px;
  margin-bottom: 18px;
  border-radius: 50%;
  object-fit: cover;
  box-shadow: 0 8px 24px rgba(31, 41, 55, 0.18);
}

.dash-hero {
  margin-bottom: 6px;
}

.dash-hero h1 {
  margin: 0;
  font-size: 32px;
  color: var(--navy-2);
}

.admin-hub-subtitle {
  margin: 0 0 28px;
  color: var(--muted);
  font-size: 16px;
}

.admin-hub-toggle-wrap {
  display: flex;
  justify-content: center;
}

.admin-hub-btn {
  padding: 16px 36px;
  border: 0;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff;
  font-size: 18px;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 10px 24px rgba(91, 69, 217, 0.35);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.admin-hub-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 14px 28px rgba(91, 69, 217, 0.4);
}

.panel-card-grid {
  display: none;
  width: 100%;
  max-width: 920px;
  margin-top: 8px;
  gap: 20px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.panel-card-grid.open {
  display: grid;
}

.panel-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 32px 20px;
  border-radius: var(--radius);
  background: #fff;
  border: 1px solid var(--line);
  box-shadow: 0 4px 16px rgba(16, 24, 39, 0.08);
}

.panel-card h3 {
  margin: 0;
  font-size: 20px;
  color: var(--navy-2);
}

/* Tarjetas del Administrador General: cada área conserva un color propio. */
.admin-hub-grid .panel-card {
  min-height: 190px;
  justify-content: center;
  border-top: 5px solid var(--primary);
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.admin-hub-grid .panel-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 14px 28px rgba(16, 24, 39, 0.14);
}

.admin-hub-grid .panel-card p { margin: -4px 0 4px; color: var(--muted); }
.admin-hub-grid .hub-maestros { border-top-color: #7c3aed; }
.admin-hub-grid .hub-admin { border-top-color: #2563eb; }
.admin-hub-grid .hub-secretaria { border-top-color: #db2777; }
.admin-hub-grid .hub-asistencia { border-top-color: #0891b2; }
.admin-hub-grid .hub-roles { border-top-color: #d97706; }

.admin-hub-grid .hub-action {
  width: min(220px, 100%);
  padding: 12px 22px;
  border-radius: 12px;
  color: #fff;
  background: #7c3aed;
  box-shadow: 0 8px 16px rgba(124, 58, 237, 0.25);
}
.admin-hub-grid .hub-admin .hub-action { background: #2563eb; box-shadow: 0 8px 16px rgba(37, 99, 235, 0.25); }
.admin-hub-grid .hub-secretaria .hub-action { background: #db2777; box-shadow: 0 8px 16px rgba(219, 39, 119, 0.25); }
.admin-hub-grid .hub-asistencia .hub-action { background: #0891b2; box-shadow: 0 8px 16px rgba(8, 145, 178, 0.25); }
.admin-hub-grid .hub-roles .hub-action { background: #d97706; box-shadow: 0 8px 16px rgba(217, 119, 6, 0.25); }
.admin-hub-grid .hub-action:hover { filter: brightness(0.93); transform: translateY(-1px); }

.button.pink {
  background: var(--pink);
}

.button.pink:hover {
  background: #e23f87;
}

.admin-hub-collapse {
  display: none;
  margin-top: 22px;
  padding: 10px 22px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}

.admin-hub-collapse:hover {
  background: var(--soft);
}

@media (max-width: 640px) {
  .panel-card-grid {
    grid-template-columns: 1fr;
  }
}

.dias-trabajo-checks {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}

.dias-trabajo-checks label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
}

/* ========== ETIQUETA "A TIEMPO / TARDE" EN LA TABLA DE ENTRADA Y SALIDA ========== */
.puntualidad-pill {
  display: inline-block;
  margin-left: 8px;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}

.puntualidad-pill.a-tiempo {
  background: #dcfce7;
  color: var(--success);
}

.puntualidad-pill.tarde {
  background: #fee2e2;
  color: var(--danger);
}

.puntualidad-pill.despues {
  background: #fef3c7;
  color: #92400e;
}

.puntualidad-pill.antes {
  background: #dbeafe;
  color: #1d4ed8;
}

.entrada-salida-comentario {
  min-width: 160px;
  min-height: 38px;
}

/* ========== OVERDUE ALERT BANNER ========== */
.overdue-alert {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 20px;
  border: 2px solid #fca5a5;
  border-radius: var(--radius);
  background: linear-gradient(135deg, #fff1f0, #fff5f5);
  box-shadow: 0 4px 18px rgba(180, 35, 24, 0.12);
  animation: alertSlideIn 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

.overdue-alert[hidden] {
  display: none;
}

@keyframes alertSlideIn {
  from { opacity: 0; transform: translateY(-10px); }
  to   { opacity: 1; transform: translateY(0); }
}

.overdue-alert-icon {
  font-size: 28px;
  line-height: 1;
  flex-shrink: 0;
  animation: alertPulse 1.8s ease-in-out infinite;
}

@keyframes alertPulse {
  0%, 100% { transform: scale(1); }
  50%       { transform: scale(1.15); }
}

.overdue-alert-body {
  flex: 1;
  min-width: 0;
}

.overdue-alert-body strong {
  display: block;
  color: #991b1b;
  font-size: 17px;
}

.overdue-alert-body span {
  color: #b42318;
  font-size: 14px;
}

.overdue-alert-action {
  flex-shrink: 0;
  min-height: 40px;
  border: 0;
  border-radius: 6px;
  padding: 0 18px;
  background: #b42318;
  color: #fff;
  font-weight: 800;
  cursor: pointer;
  font: inherit;
  white-space: nowrap;
}

.overdue-alert-action:hover {
  background: #8f1d14;
}

.overdue-alert-close {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border: 1px solid #fca5a5;
  border-radius: 50%;
  background: #fff;
  color: #b42318;
  font-size: 14px;
  font-weight: 900;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font: inherit;
}

.overdue-alert-close:hover {
  background: #fee2e2;
}

/* ========== CLICKABLE SEARCH ROWS ========== */
.search-clickable-table tbody tr.search-row {
  cursor: pointer;
  transition: background 0.12s;
}

.search-clickable-table tbody tr.search-row:hover {
  background: #ede9ff;
}

.fill-hint {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--primary);
  color: #fff;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
  opacity: 0;
  transition: opacity 0.15s;
}

.search-row:hover .fill-hint {
  opacity: 1;
}

/* Highlight form when filled from search */
@keyframes formHighlight {
  0%   { box-shadow: 0 0 0 0 rgba(91, 69, 217, 0.5); }
  60%  { box-shadow: 0 0 0 10px rgba(91, 69, 217, 0); }
  100% { box-shadow: 0 0 0 0 rgba(91, 69, 217, 0); }
}

.form-filled-highlight {
  animation: formHighlight 0.7s ease-out;
}
/* ========== MAESTROS ========== */
.hero-metrics.hero-metrics-4 {
  grid-template-columns: repeat(4, minmax(120px, 1fr));
}

.quick-grid.quick-grid-2 {
  grid-template-columns: repeat(2, minmax(220px, 1fr));
}

.maestros-form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 18px;
  align-items: end;
  padding: 24px;
}

.maestros-form .form-field.wide {
  grid-column: span 2;
}

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

.maestros-form textarea.input {
  min-height: 90px;
  height: auto;
  padding: 12px 16px;
  resize: vertical;
  font: inherit;
}

.maestros-toolbar {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) 180px auto;
  gap: 10px;
  align-items: end;
  padding: 18px 24px 8px;
}

.maestros-toolbar.two-col {
  grid-template-columns: minmax(220px, 1fr) auto;
}

.maestros-toolbar.single-col {
  grid-template-columns: 1fr;
}

.maestros-cell-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.maestros-cell-actions .button {
  min-height: 38px;
  padding: 0 14px;
  font-size: 13px;
}

@media (max-width: 760px) {
  .hero-metrics.hero-metrics-4 {
    grid-template-columns: repeat(2, minmax(120px, 1fr));
  }

  .quick-grid.quick-grid-2 {
    grid-template-columns: 1fr;
  }

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

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

  .maestros-toolbar,
  .maestros-toolbar.two-col {
    grid-template-columns: 1fr;
  }
}

/* ========== PORTAL SWITCHER (solo admin definitivo) ========== */
.sidebar-portal-switch {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.14);
  display: grid;
  gap: 8px;
}

.sidebar-portal-label {
  color: rgba(255, 255, 255, 0.55);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 800;
  padding: 0 14px;
}
/* ========== ESTATUS DE PAGO POR PERIODO (verde/rojo/beca/aviso) ========== */
.status-pill.pago-ok {
  color: #116149;
  background: #dff7ed;
}

.status-pill.pago-pendiente {
  color: #8f1d14;
  background: #ffe2df;
}

.status-pill.pago-beca {
  color: #8a6d0a;
  background: #fff3d6;
}

.status-pill.pago-aviso {
  color: #6b2d97;
  background: #f1e6ff;
}

.status-pill.pago-na {
  color: #667085;
  background: #eef2f7;
}

.status-pill.pago-no-pagado {
  color: #fff;
  background: #b42318;
}

.mensualidad-limite-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding: 10px 14px;
  border-radius: var(--radius);
  background: var(--soft);
  border: 1px solid var(--line);
  margin-bottom: 12px;
  font-size: 13px;
}

.mensualidad-limite-no-pagado {
  background: #fee2e2;
  border-color: #fecaca;
}

.alumno-info-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 10px 14px;
  border-radius: var(--radius);
  background: var(--soft);
  border: 1px solid var(--line);
  margin-bottom: 12px;
  font-size: 13px;
}

.inline-edit-alumno-form {
  margin-bottom: 12px;
}

.recargo-note {
  color: #b91c1c;
  font-size: 12px;
  font-weight: 600;
}

/* ========== FILAS CLICABLES (detalle de alumno) ========== */
.clickable-row {
  cursor: pointer;
}

.clickable-row:hover {
  background: #f7f9fc;
}

/* ========== ESCANEO DE CÓDIGO DE BARRAS (libros) ========== */
.barcode-scan-field {
  display: flex;
  gap: 6px;
  align-items: center;
}

.barcode-scan-field .input {
  flex: 1;
}

.barcode-scan-btn {
  padding: 0 12px;
  font-size: 16px;
  min-height: 44px;
  flex-shrink: 0;
}

.scan-video {
  width: 100%;
  border-radius: 8px;
  background: #000;
  max-height: 320px;
  object-fit: cover;
}

.scan-hint {
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-backdrop.hidden {
  display: none;
}

.modal-box {
  width: min(480px, 100%);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.22);
  overflow: hidden;
}

.modal-box .modal-body {
  padding: 22px;
  display: grid;
  gap: 14px;
}

/* ========== HISTORIAL DE ALUMNO (fila expandible hacia abajo) ========== */
.expand-arrow {
  display: inline-block;
  margin-right: 8px;
  font-size: 11px;
  color: var(--muted);
  transition: transform 0.15s ease;
}

.clickable-row.row-expanded .expand-arrow {
  transform: rotate(90deg);
}

.clickable-row.row-expanded {
  background: #f7f9fc;
}

tr.detail-row {
  background: #f7f9fc;
}

tr.detail-row:hover {
  background: #f7f9fc;
}

tr.detail-row td {
  white-space: normal;
  padding: 20px 24px 24px;
  border-bottom: 1px solid var(--line);
}

.student-history {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}

.student-history.admin-history {
  grid-template-columns: 1fr;
}

.row-actions-btn {
  min-height: 28px;
  padding: 2px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--danger);
  background: #fff;
  cursor: pointer;
  font-weight: 700;
  font-size: 12px;
  margin-right: 4px;
}

.row-actions-btn.edit {
  color: var(--primary);
}

.row-actions-btn:hover {
  background: #fee2e2;
}

.row-actions-btn.edit:hover {
  background: var(--soft);
}

.student-history-col.full-width {
  grid-column: 1 / -1;
}

.student-history .pago-form {
  margin-top: 12px;
}

.student-history-col h4 {
  margin: 0 0 10px;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--muted);
}

.student-history-col .mini-table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}

.student-history-col .mini-table th,
.student-history-col .mini-table td {
  padding: 8px 12px;
  font-size: 13px;
  white-space: nowrap;
}

.student-history-col .mini-table th {
  background: #f0f2f6;
}

.empty-state-inline {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

@media (max-width: 720px) {
  .student-history {
    grid-template-columns: 1fr;
  }
}

/* ========== MODALIDAD: chip con botón de renombrar ========== */
.modalidad-chip {
  display: inline-flex;
  align-items: center;
  position: relative;
}

.modalidad-chip > .button { padding-right: 20px; }

.modalidad-edit-btn {
  position: absolute;
  z-index: 1;
  top: -9px;
  right: 15px;
  border: 1px solid #d7d1ff;
  background: #fff;
  border-radius: 50%;
  width: 23px;
  height: 23px;
  padding: 0;
  min-height: 23px;
  cursor: pointer;
  font-size: 13px;
  color: var(--primary);
  box-shadow: 0 2px 6px rgba(31, 36, 48, .16);
  opacity: 0;
  pointer-events: none;
  transform: translateY(3px) scale(.85);
  transition: opacity .16s ease, transform .16s ease, background .16s ease;
}

.modalidad-edit-btn:hover {
  background: #f0f2f6;
  color: var(--text);
}

.modalidad-chip .modalidad-delete-btn {
  position: absolute;
  z-index: 1;
  top: -9px;
  right: -10px;
  min-width: 23px;
  min-height: 23px;
  padding: 0;
  border: 1px solid #f3b8b4;
  border-radius: 50%;
  color: #fff;
  background: #c62820;
  font-size: 18px;
  line-height: 19px;
  box-shadow: 0 2px 6px rgba(31, 36, 48, .16);
  opacity: 0;
  pointer-events: none;
  transform: translateY(3px) scale(.85);
  transition: opacity .16s ease, transform .16s ease, background .16s ease;
}
.modalidad-chip:hover .modalidad-edit-btn,
.modalidad-chip:hover .modalidad-delete-btn,
.modalidad-chip:focus-within .modalidad-edit-btn,
.modalidad-chip:focus-within .modalidad-delete-btn { opacity: 1; pointer-events: auto; transform: translateY(0) scale(1); }
.modalidad-chip .modalidad-edit-btn:hover { background: #f3f0ff; }
.modalidad-chip .modalidad-delete-btn:hover { background: #a91e18; }

/* ========== MODAL DE DETALLE DE ALUMNO ========== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 20, 30, 0.55);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 40px 16px;
  overflow-y: auto;
  z-index: 1000;
}

.modal-overlay[hidden] {
  display: none;
}

.modal-card {
  position: relative;
  background: #fff;
  border-radius: 16px;
  padding: 28px;
  max-width: 720px;
  width: 100%;
  box-shadow: 0 20px 60px rgba(15, 20, 30, 0.25);
}

.modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 32px;
  height: 32px;
  min-height: 32px;
  border-radius: 8px;
  border: 1px solid #dfe3ea;
  background: #fff;
  cursor: pointer;
  font-size: 14px;
}

.modal-close:hover {
  background: #f0f2f6;
}

.modal-header h3 {
  margin: 0 0 4px;
}

.modal-header p {
  margin: 4px 0;
  color: #667085;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.modal-body h4 {
  margin: 20px 0 10px;
}

.pago-form {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin: 0;
  padding: 16px 24px 24px;
  align-items: end;
}

.pago-form .button {
  grid-column: 1 / -1;
}

@media (max-width: 640px) {
  .pago-form {
    grid-template-columns: 1fr;
  }

  .modal-card {
    padding: 20px;
  }
}

/* Estilos exclusivos de la página Reportes (no toca styles.css) */

:root {
  --diag-red: #ee2222;
  --diag-teal: #1f5f74;
  --diag-teal-dark: #163f4d;
  --diag-orange: #e2672a;
}

.reportes-hint {
  color: var(--muted);
  margin: 0 0 18px;
}

/* Mensajes de ayuda dentro de una tarjeta: mantenerlos separados del borde. */
.section > .reportes-hint,
.section > .excel-hint {
  margin: 0;
  padding: 16px 24px 8px;
  line-height: 1.5;
}

.reporte-detalle-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}

.reporte-detalle-header h2 {
  margin: 0;
  font-size: 20px;
}

.reporte-detalle-actions {
  display: flex;
  gap: 10px;
}

/* --- Tarjeta de diagnóstico (estilo reporte imprimible) --- */

#reporteDetalleWrap {
  margin: 8px auto 0;
  max-width: 900px;
}

.diag-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: 0 18px 50px rgba(16, 24, 39, 0.12);
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
  color-adjust: exact;
}

.diag-topbar {
  height: 14px;
  background: var(--diag-red);
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
  color-adjust: exact;
}

.diag-header {
  background: var(--diag-teal-dark);
  color: #fff;
  padding: 28px 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
  color-adjust: exact;
}

.diag-header h2 {
  margin: 0 0 8px;
  font-size: 22px;
  letter-spacing: 0.03em;
}

.diag-header p {
  margin: 2px 0;
  font-size: 13px;
  color: #cfe3ea;
}

.diag-logo {
  width: 66px;
  height: 66px;
  border-radius: 50%;
  object-fit: contain;
  background: #fff;
  flex: none;
}

.diag-body {
  padding: 28px 32px;
  display: grid;
  gap: 28px;
}

.diag-general h3,
.diag-chart-card h3,
.diag-table-block h3,
.diag-stats-block h3,
.diag-feedback h3 {
  margin: 0 0 14px;
  font-size: 15px;
  color: var(--diag-orange);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.diag-field {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 16px;
}

.diag-field span {
  color: var(--muted);
  font-size: 13px;
}

.diag-field strong {
  font-size: 18px;
}

.diag-grade-box {
  display: inline-flex;
  flex-direction: column;
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px 22px;
  margin-bottom: 18px;
}

.diag-grade-box span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.diag-grade-box strong {
  font-size: 34px;
  color: var(--diag-teal-dark);
}

.diag-meta-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
}

.diag-meta-grid div {
  display: grid;
  gap: 2px;
}

.diag-meta-grid span {
  color: var(--muted);
  font-size: 12px;
}

.diag-meta-grid strong {
  font-size: 15px;
}

.diag-charts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 20px;
}

.diag-chart-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  overflow-x: auto;
}

.diag-chart-svg {
  width: 100%;
  height: auto;
  min-width: 320px;
}

.diag-two-col {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 20px;
}

.diag-stats-block {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
}

.diag-stats-block p {
  margin: 6px 0;
  color: var(--text);
}

.diag-cumplimiento {
  font-size: 20px;
  font-weight: 800;
  color: var(--diag-teal-dark);
}

.diag-feedback {
  border-top: 1px solid var(--line);
  padding-top: 20px;
}

.diag-obs-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 14px;
  margin-bottom: 10px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.diag-obs-item p {
  margin: 6px 0 0;
  width: 100%;
  color: var(--text);
}

.diag-obs-fecha {
  color: var(--muted);
  font-size: 13px;
}

.diag-muted-row {
  color: var(--muted);
  text-align: center;
  padding: 16px;
}

.diag-bottombar {
  background: var(--diag-red);
  color: #fff;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  text-align: center;
  padding: 26px 20px;
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
  color-adjust: exact;
}

.diag-bottombar span {
  display: block;
  font-size: 13px;
  opacity: 0.9;
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.diag-bottombar strong {
  font-size: 34px;
}

.diag-footer {
  background: var(--diag-teal-dark);
  color: #cfe3ea;
  text-align: center;
  padding: 16px;
  font-size: 12px;
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
  color-adjust: exact;
}

.diag-footer p {
  margin: 2px 0;
}

@media (max-width: 860px) {
  .diag-two-col {
    grid-template-columns: 1fr;
  }
  .diag-header {
    flex-direction: column;
    text-align: center;
  }
  .diag-bottombar {
    grid-template-columns: 1fr;
    gap: 18px;
  }
}

/* --- Impresión / descarga en PDF --- */
@media print {
  @page {
    size: letter;
    margin: 8mm;
  }

  html, body {
    background: #fff !important;
  }

  * {
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
    color-adjust: exact !important;
  }

  body * {
    visibility: hidden;
  }

  #reporteDetalleWrap,
  #reporteDetalleWrap * {
    visibility: visible;
  }

  #reporteDetalleWrap {
    position: absolute;
    inset: 0;
    margin: 0 auto;
    max-width: 100%;
    padding: 0;
  }

  .no-print {
    display: none !important;
  }

  .diag-card {
    box-shadow: none;
    border: none;
    border-radius: 0;
    max-width: 100%;
  }

  .diag-charts {
    grid-template-columns: 1fr 1fr;
    page-break-inside: avoid;
  }

  .diag-chart-card {
    overflow-x: visible;
    page-break-inside: avoid;
  }

  .diag-two-col {
    page-break-inside: avoid;
  }

  .diag-bottombar,
  .diag-footer,
  .diag-header {
    page-break-inside: avoid;
  }

  .diag-obs-item {
    page-break-inside: avoid;
  }

  /* Todo el reporte compactado para caber en una sola hoja */
  #reporteDetalleWrap {
    font-size: 11px;
  }

  .diag-header {
    padding: 12px 20px;
  }

  .diag-header h2 {
    font-size: 15px;
    margin: 0 0 4px;
  }

  .diag-header p {
    font-size: 9px;
    margin: 1px 0;
  }

  .diag-logo {
    width: 38px;
    height: 38px;
  }

  .diag-body {
    padding: 12px 20px;
    gap: 10px;
  }

  .diag-general h3,
  .diag-chart-card h3,
  .diag-table-block h3,
  .diag-stats-block h3,
  .diag-feedback h3 {
    font-size: 10px;
    margin: 0 0 6px;
  }

  .diag-field {
    margin-bottom: 8px;
  }

  .diag-field span {
    font-size: 10px;
  }

  .diag-field strong {
    font-size: 13px;
  }

  .diag-grade-box {
    padding: 6px 14px;
    margin-bottom: 10px;
  }

  .diag-grade-box strong {
    font-size: 22px;
  }

  .diag-meta-grid {
    gap: 6px 14px;
  }

  .diag-meta-grid span {
    font-size: 9px;
  }

  .diag-meta-grid strong {
    font-size: 11px;
  }

  .diag-charts {
    gap: 10px;
  }

  .diag-chart-card {
    padding: 8px;
  }

  .diag-chart-svg {
    width: 100%;
    height: 100px;
    min-width: 0;
  }

  .diag-two-col {
    gap: 10px;
  }

  #reporteDetalleWrap th,
  #reporteDetalleWrap td {
    padding: 4px 8px !important;
    font-size: 9px;
    white-space: normal;
  }

  #reporteDetalleWrap .status-pill {
    min-height: 18px;
    padding: 0 8px;
    font-size: 9px;
  }

  #reporteDetalleWrap tbody tr:nth-child(n + 5) {
    display: none;
  }

  .diag-stats-block {
    padding: 8px;
  }

  .diag-stats-block p {
    margin: 3px 0;
    font-size: 10px;
  }

  .diag-cumplimiento {
    font-size: 14px;
  }

  .diag-feedback {
    padding-top: 10px;
  }

  .diag-obs-item {
    padding: 6px 10px;
    margin-bottom: 6px;
    gap: 6px;
    font-size: 9px;
  }

  .diag-obs-item p {
    margin: 4px 0 0;
    font-size: 9px;
  }

  .diag-obs-fecha {
    font-size: 9px;
  }

  .diag-feedback .diag-obs-item:nth-child(n + 3) {
    display: none;
  }

  .diag-bottombar {
    padding: 12px 16px;
  }

  .diag-bottombar span {
    font-size: 9px;
    margin-bottom: 4px;
  }

  .diag-bottombar strong {
    font-size: 20px;
  }

  .diag-footer {
    padding: 8px;
    font-size: 8px;
  }
}
/* ========== TOAST FLOTANTE (avisos rápidos en cualquier página) ========== */
#appToast {
  position: fixed;
  bottom: 28px;
  right: 28px;
  z-index: 9999;
  max-width: 360px;
  padding: 14px 22px;
  border-radius: 8px;
  background: #b42318;
  color: #fff;
  font-weight: 800;
  font-size: 15px;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.18);
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 0.25s, transform 0.25s;
  pointer-events: none;
}

#appToast.show {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 640px) {
  #appToast {
    left: 16px;
    right: 16px;
    bottom: 16px;
    max-width: none;
  }
}

/* ========== META / LÍMITE (barra de progreso: ingresos y egresos a lograr) ========== */
.meta-form {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin: 0;
  padding: 20px 24px 12px;
}

.meta-form label {
  font-weight: 800;
  font-size: 14px;
}

.meta-form .input {
  max-width: 180px;
}

.meta-bar-track {
  position: relative;
  width: 100%;
  height: 320px;
  background: var(--soft);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}

.meta-bar-fill {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 0%;
  background: #ef4444;
  transition: height 0.3s ease, background 0.3s ease;
}

.meta-bar-fill.meta-half { background: #f59e0b; }
.meta-bar-fill.meta-over { background: #16a34a; }

.meta-bar-limit-line {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 100%;
  border-top: 2px dashed #1f2430;
}

.meta-bar-percent {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 32px;
  font-weight: 900;
  color: #1f2430;
  pointer-events: none;
}

.meta-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin: 0;
  padding: 8px 24px 20px;
  font-size: 14px;
}

.meta-legend {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 13px;
}

.meta-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-right: 6px;
}

.meta-dot-limit { background: #1f2430; }
.meta-dot-over { background: #16a34a; }
.meta-dot-close { background: #eab308; }
.meta-dot-half { background: #f97316; }
.meta-dot-low { background: #ef4444; }

.meta-timeline-wrap {
  margin-top: 0;
  padding: 20px 24px 24px;
  border-top: 1px solid var(--line);
}

.meta-timeline-wrap h4 {
  margin: 0 0 12px;
  font-size: 15px;
}

/* ========== LÍMITE DE EGRESOS (goal-tracker con SVG) ========== */
.goal-tracker {
  padding: 20px 24px 24px;
}

.input-sanitized {
  outline: 2px solid #f59e0b;
  outline-offset: 1px;
}

.goal-tracker-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}

.goal-tracker-row label {
  font-weight: 800;
  font-size: 14px;
}

.goal-tracker-row .input {
  max-width: 180px;
}

.goal-chart-wrap {
  width: 100%;
  background: var(--soft);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
}

.goal-chart {
  width: 100%;
  height: auto;
  display: block;
}

.goal-bar-labels {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 14px;
  font-size: 14px;
}

.goal-status-pill {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 999px;
  font-weight: 800;
  font-size: 13px;
  background: #f1f2f6;
  color: var(--muted);
}

.goal-status-pill.goal-status-green { background: #dcfce7; color: #15803d; }
.goal-status-pill.goal-status-yellow { background: #fef3c7; color: #b45309; }
.goal-status-pill.goal-status-red { background: #fee2e2; color: #b42318; }

.goal-bar-legend {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 13px;
  margin-top: 10px;
}

.goal-mark, .goal-green, .goal-yellow, .goal-red {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-right: 6px;
}

.goal-mark { background: #1f2430; }
.goal-green { background: #16a34a; }
.goal-yellow { background: #f59e0b; }
.goal-red { background: #b42318; }

/* ========== TOOLTIP PROPIO PARA GRÁFICAS (hover en puntos) ========== */
.chart-tooltip {
  position: fixed;
  display: none;
  z-index: 9999;
  background: linear-gradient(180deg, #2a3142, #1f2430);
  color: #fff;
  padding: 8px 14px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.1px;
  box-shadow: 0 10px 24px rgba(15, 18, 30, 0.28);
  border: 1px solid rgba(255, 255, 255, 0.08);
  pointer-events: none;
  width: max-content;
  max-width: min(280px, calc(100vw - 24px));
  white-space: normal;
  word-wrap: break-word;
  line-height: 1.45;
}
/* Aviso de sesión y alertas disponible en todas las áreas. */
.role-alert-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 52px;
  box-sizing: border-box;
  padding: 9px 24px 9px 76px;
  color: #5f1f45;
  background: #fff0f6;
  border-bottom: 1px solid #f6c6dc;
  font-size: 13px;
  font-weight: 700;
}
.role-alert-bar a { color: #8b1e57; text-decoration: underline; white-space: nowrap; }
.password-field { position: relative; }
.password-field .input { padding-right: 82px; }
.password-toggle { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); border: 0; background: transparent; color: #5c2cc4; font-weight: 700; cursor: pointer; }
.roles-page { max-width: 1100px; margin: 36px auto; padding: 0 20px 48px; }
.roles-header { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 22px; }
.roles-card { background: #fff; border-radius: 16px; box-shadow: 0 8px 25px rgba(93, 31, 67, .10); padding: 24px; margin-bottom: 22px; }
.roles-form { display: grid; grid-template-columns: 1.4fr 1fr 1fr auto; gap: 12px; align-items: end; }
.roles-table { width: 100%; border-collapse: collapse; }
.roles-table th, .roles-table td { padding: 12px 8px; text-align: left; border-bottom: 1px solid #f0dbe5; }
.roles-table select { min-width: 140px; }
.approve-button { background: #0f766e; }
.approve-button:hover { background: #0b5d57; }
@media (max-width: 720px) { .roles-form { grid-template-columns: 1fr; } .roles-header { align-items: flex-start; flex-direction: column; } .roles-table { font-size: 13px; } .role-alert-bar { padding-right: 14px; font-size: 12px; } }
