:root {
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #172033;
  background: #f5f7fb;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  --primary: #173b67;
  --primary-2: #245d9c;
  --accent: #d9a441;
  --success: #16794b;
  --danger: #b42318;
  --text: #172033;
  --muted: #667085;
  --line: #dbe2ea;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --shadow: 0 12px 35px rgba(23, 59, 103, 0.08);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background:
    radial-gradient(circle at top right, rgba(36, 93, 156, 0.08), transparent 32rem),
    #f5f7fb;
}

button, input, select, textarea { font: inherit; }
button { cursor: pointer; }

.app-shell { min-height: 100vh; }

.hero {
  background: linear-gradient(135deg, #12345b 0%, #1b4d82 62%, #2867a9 100%);
  color: white;
  padding: 28px 20px 70px;
}

.hero-inner, .main-wrap { max-width: 1240px; margin: 0 auto; }

.eyebrow {
  margin: 0 0 7px;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: #d9e7f7;
}

.hero h1 { margin: 0; font-size: clamp(1.8rem, 3vw, 2.65rem); line-height: 1.08; }
.hero p { margin: 10px 0 0; max-width: 760px; color: #e9f0f9; line-height: 1.55; }

.main-wrap { margin-top: -42px; padding: 0 20px 48px; }

.toolbar {
  background: var(--surface);
  border: 1px solid rgba(219, 226, 234, 0.9);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 15px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  position: sticky;
  top: 10px;
  z-index: 20;
}

.toolbar-spacer { flex: 1; }

.btn {
  border: 1px solid var(--line);
  background: white;
  color: var(--text);
  border-radius: 10px;
  padding: 10px 14px;
  font-weight: 750;
  transition: .18s ease;
}
.btn:hover { transform: translateY(-1px); border-color: #b8c4d1; }
.btn-primary { background: var(--primary); color: white; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-2); }
.btn-success { background: var(--success); color: white; border-color: var(--success); }
.btn-danger-ghost { color: var(--danger); background: #fff; }
.btn-small { padding: 7px 10px; font-size: .88rem; }
.btn-icon { display: inline-flex; gap: 7px; align-items: center; }

.progress-box {
  margin-top: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 12px;
  display: grid;
  grid-template-columns: repeat(6, minmax(120px, 1fr));
  gap: 8px;
  overflow-x: auto;
}

.step-tab {
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 11px 12px;
  border-radius: 10px;
  font-weight: 750;
  white-space: nowrap;
}
.step-tab.active { background: #eaf2fb; color: var(--primary); }
.step-tab .step-number {
  display: inline-grid;
  place-items: center;
  width: 24px;
  height: 24px;
  margin-right: 6px;
  border-radius: 50%;
  background: #eef2f6;
  color: #475467;
  font-size: .8rem;
}
.step-tab.active .step-number { background: var(--primary); color: #fff; }

.form-card {
  margin-top: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: 0 7px 24px rgba(15, 23, 42, .04);
  padding: 22px;
}

.section-title { display: flex; justify-content: space-between; gap: 14px; align-items: flex-start; margin-bottom: 18px; }
.section-title h2 { margin: 0; font-size: 1.45rem; color: var(--primary); }
.section-title p { margin: 6px 0 0; color: var(--muted); line-height: 1.5; }

.subsection {
  border-top: 1px solid var(--line);
  margin-top: 24px;
  padding-top: 22px;
}
.subsection:first-of-type { border-top: 0; margin-top: 0; padding-top: 0; }
.subsection h3 { margin: 0 0 13px; font-size: 1.02rem; }
.subsection-note { margin: -5px 0 14px; color: var(--muted); font-size: .92rem; }

.grid { display: grid; gap: 14px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.col-span-2 { grid-column: span 2; }
.col-span-full { grid-column: 1 / -1; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: .86rem; font-weight: 760; color: #344054; }
.field small { color: var(--muted); line-height: 1.35; }
.required::after { content: " *"; color: var(--danger); }

input, select, textarea {
  width: 100%;
  border: 1px solid #cfd8e3;
  border-radius: 10px;
  background: #fff;
  color: var(--text);
  padding: 10px 11px;
  outline: none;
  transition: border-color .18s ease, box-shadow .18s ease;
}
input:focus, select:focus, textarea:focus {
  border-color: #5b8ec1;
  box-shadow: 0 0 0 3px rgba(36, 93, 156, .12);
}
textarea { min-height: 82px; resize: vertical; }

.checkbox-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 9px; }
.check-card {
  display: flex;
  align-items: center;
  gap: 9px;
  border: 1px solid var(--line);
  background: var(--surface-soft);
  border-radius: 10px;
  padding: 10px;
  font-weight: 650;
  color: #344054;
}
.check-card input { width: 17px; height: 17px; margin: 0; accent-color: var(--primary); }

.repeater-list { display: grid; gap: 12px; }
.repeater-card {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fbfcfe;
  padding: 15px;
}
.repeater-head { display: flex; justify-content: space-between; gap: 10px; align-items: center; margin-bottom: 13px; }
.repeater-head strong { color: var(--primary); }
.row-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.inline-add {
  margin-top: 12px;
  display: flex;
  justify-content: flex-start;
}

.empty-state {
  border: 1px dashed #b9c6d5;
  background: #f8fafc;
  border-radius: 12px;
  color: var(--muted);
  text-align: center;
  padding: 20px;
}

.stat-chip {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  border-radius: 999px;
  padding: 6px 10px;
  background: #e9f5ef;
  color: #0f6b41;
  font-weight: 800;
  font-size: .85rem;
}

.step-footer {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-top: 20px;
}

.hidden { display: none !important; }

.notice {
  border-left: 4px solid var(--accent);
  background: #fff9ec;
  color: #6b4f18;
  padding: 12px 14px;
  border-radius: 8px;
  line-height: 1.45;
  margin-bottom: 16px;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  max-width: 360px;
  background: #101828;
  color: white;
  border-radius: 12px;
  padding: 12px 15px;
  box-shadow: 0 14px 40px rgba(16, 24, 40, .25);
  z-index: 50;
  opacity: 0;
  transform: translateY(12px);
  pointer-events: none;
  transition: .2s ease;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.success { background: #11633d; }
.toast.error { background: #9f2d20; }

.mini-table { width: 100%; border-collapse: separate; border-spacing: 0; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.mini-table th, .mini-table td { padding: 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
.mini-table th { background: #f3f6fa; color: #344054; font-size: .85rem; }
.mini-table tr:last-child td { border-bottom: 0; }
.mini-table input, .mini-table select { min-width: 110px; }
.table-wrap { overflow-x: auto; }

@media (max-width: 900px) {
  .grid-4, .grid-3, .checkbox-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .progress-box { grid-template-columns: repeat(6, minmax(145px, 1fr)); }
}

@media (max-width: 640px) {
  .hero { padding-top: 22px; }
  .main-wrap { padding-inline: 12px; }
  .toolbar { top: 5px; }
  .toolbar-spacer { display: none; }
  .grid-2, .grid-3, .grid-4, .checkbox-grid { grid-template-columns: 1fr; }
  .col-span-2 { grid-column: span 1; }
  .form-card { padding: 16px; }
  .section-title { flex-direction: column; }
  .step-footer { flex-direction: column-reverse; }
  .step-footer .btn { width: 100%; }
}

/* Dashboard por centro educativo */
.dashboard-toolbar,
.dashboard-search,
.summary-hero-card {
  margin-top: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
}

.dashboard-toolbar {
  padding: 20px;
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: center;
}

.dashboard-toolbar h2,
.summary-hero-card h2 {
  margin: 0;
  color: var(--primary);
}

.dashboard-toolbar p,
.summary-hero-card p {
  margin: 6px 0 0;
  color: var(--muted);
  line-height: 1.5;
}

.dashboard-actions {
  display: flex;
  gap: 9px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.dashboard-search {
  padding: 16px;
  display: grid;
  grid-template-columns: minmax(260px, 1fr) minmax(380px, 1.6fr);
  gap: 14px;
  align-items: center;
}

.dashboard-search input {
  min-height: 44px;
}

.storage-note {
  background: #f1f6fc;
  border: 1px solid #d6e5f4;
  color: #36516f;
  border-radius: 12px;
  padding: 11px 13px;
  line-height: 1.45;
  font-size: .9rem;
}

.school-group {
  margin-top: 22px;
}

.group-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}

.group-heading h3 {
  margin: 0;
  color: var(--primary);
  font-size: 1.05rem;
}

.group-heading span {
  color: var(--muted);
  font-size: .86rem;
  font-weight: 700;
}

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

.school-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 16px;
  box-shadow: 0 6px 20px rgba(15, 23, 42, .035);
  display: flex;
  flex-direction: column;
  min-height: 225px;
}

.school-card.has-data {
  border-color: #bddbc9;
  box-shadow: 0 8px 24px rgba(22, 121, 75, .06);
}

.school-card-top {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: center;
}

.school-card-top small {
  color: var(--muted);
  text-align: right;
  font-size: .75rem;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  border-radius: 999px;
  padding: 4px 8px;
  background: #f2f4f7;
  color: #667085;
  font-size: .75rem;
  font-weight: 800;
}

.status-badge.started {
  background: #e9f5ef;
  color: #0f6b41;
}

.school-card h4 {
  margin: 14px 0 10px;
  color: #24364b;
  font-size: 1rem;
  line-height: 1.4;
}

.school-empty-copy {
  margin: 0;
  color: var(--muted);
  font-size: .9rem;
  line-height: 1.45;
}

.school-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 7px;
  margin: 2px 0 14px;
}

.school-stats span {
  background: #f7f9fc;
  border: 1px solid #e6ebf1;
  border-radius: 9px;
  padding: 8px 7px;
  text-align: center;
  color: var(--muted);
  font-size: .72rem;
}

.school-stats strong {
  display: block;
  color: var(--primary);
  font-size: 1rem;
}

.school-actions {
  margin-top: auto;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.current-school {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 240px;
  max-width: 420px;
}

.current-school small {
  color: var(--muted);
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
}

.current-school strong {
  color: var(--primary);
  line-height: 1.3;
}

.readonly-value {
  min-height: 42px;
  display: flex;
  align-items: center;
  padding: 10px 12px;
  background: #f2f5f9;
  border: 1px solid #d9e1ea;
  border-radius: 10px;
  color: #344054;
  font-weight: 750;
}

.summary-toolbar {
  position: sticky;
  top: 10px;
  z-index: 20;
}

.summary-hero-card {
  padding: 22px;
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: center;
}

.eyebrow.dark {
  color: #537398;
}

.summary-counts {
  display: grid;
  grid-template-columns: repeat(2, minmax(130px, 1fr));
  gap: 8px;
  min-width: 310px;
}

.summary-counts span {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #f8fafc;
  padding: 10px;
  text-align: center;
  color: var(--muted);
  font-size: .82rem;
}

.summary-counts strong {
  display: block;
  color: var(--primary);
  font-size: 1.25rem;
}

.summary-section h3 {
  margin: 0 0 16px;
  color: var(--primary);
  font-size: 1.18rem;
}

.summary-section h4 {
  margin: 20px 0 9px;
  color: #344054;
}

.summary-values-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.summary-value {
  border: 1px solid var(--line);
  border-radius: 11px;
  padding: 10px 12px;
  background: #fbfcfe;
}

.summary-value span,
.summary-block > span {
  display: block;
  color: var(--muted);
  font-size: .76rem;
  font-weight: 750;
  text-transform: uppercase;
  letter-spacing: .035em;
  margin-bottom: 5px;
}

.summary-value strong {
  color: #25364a;
  line-height: 1.35;
}

.summary-block {
  margin-top: 14px;
  border-top: 1px solid var(--line);
  padding-top: 14px;
}

.summary-block p {
  margin: 6px 0 0;
  color: #475467;
  line-height: 1.55;
}

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.tag {
  display: inline-flex;
  align-items: center;
  min-height: 29px;
  padding: 5px 9px;
  border-radius: 999px;
  background: #eaf2fb;
  color: var(--primary);
  font-size: .82rem;
  font-weight: 750;
}

.summary-program-block {
  margin-top: 16px;
  border-top: 1px solid var(--line);
  padding-top: 2px;
}

.empty-state.compact {
  padding: 12px;
  text-align: left;
}

.summary-table td {
  white-space: pre-wrap;
}

@media (max-width: 1000px) {
  .school-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dashboard-search { grid-template-columns: 1fr; }
  .summary-values-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 760px) {
  .dashboard-toolbar,
  .summary-hero-card {
    flex-direction: column;
    align-items: stretch;
  }
  .dashboard-actions { justify-content: flex-start; }
  .school-grid { grid-template-columns: 1fr; }
  .summary-counts { min-width: 0; }
  .form-toolbar .current-school { order: -1; width: 100%; max-width: none; }
  .summary-values-grid { grid-template-columns: 1fr; }
}

/* Versión centralizada */
.session-chip {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  padding: 8px 12px;
  border-radius: 999px;
  background: #e9f5ef;
  color: #0f6b41;
  font-weight: 800;
  font-size: .86rem;
}

.migration-notice {
  margin-top: 16px;
  border: 1px solid #a9d6be;
  background: #eefaf3;
  border-radius: 16px;
  padding: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}
.migration-notice p { margin: 4px 0 0; color: #315f49; }

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(12, 27, 48, .66);
  backdrop-filter: blur(3px);
}
.login-modal {
  width: min(440px, 100%);
  display: grid;
  gap: 15px;
  background: white;
  border-radius: 18px;
  padding: 22px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, .28);
}
.login-modal h2 { margin: 0; color: var(--primary); }
.login-modal p { margin: 0; color: var(--muted); line-height: 1.45; }
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.loading-card { text-align: center; padding: 44px 22px; }
.loading-card h2 { color: var(--primary); }

@media (max-width: 760px) {
  .migration-notice { align-items: stretch; flex-direction: column; }
  .session-chip { width: 100%; justify-content: center; }
}

.access-card {
  max-width: 620px;
  margin: 0 auto;
  background: white;
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: var(--shadow);
  padding: 32px;
  text-align: center;
}
.access-card h2 { margin: 4px 0 10px; color: var(--primary); }
.access-card p:not(.eyebrow) { color: var(--muted); line-height: 1.6; margin: 0 0 22px; }
