*, *::before, *::after { box-sizing: border-box; }

html, body {
  font-family: var(--font-base);
  font-size: 15px;
  line-height: 1.5;
  background: var(--bg-page);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  letter-spacing: 0.01em;
}

@keyframes pageReveal {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes dropdownReveal {
  from { opacity: 0; transform: translateY(-6px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes alertPop {
  from { opacity: 0; transform: scale(0.96); }
  to { opacity: 1; transform: scale(1); }
}

.form-panel,
.tabla-panel,
.config-panel,
.panel-card,
.page-shell,
.overview-card,
.hero-panel,
.progress-placeholder,
.quick-link-tile,
.share-message-box {
  background: var(--bg-surface);
  border-radius: var(--r-lg);
  padding: var(--sp-6);
  border: 1px solid var(--border-light);
  box-shadow: var(--shadow-sm);
  min-width: 0;
}

.page-shell {
  animation: pageReveal 0.28s var(--ease) both;
}

.panel-header,
.section-heading {
  margin-bottom: var(--sp-5);
}

.panel-header h2,
.section-heading h2 {
  margin: 0;
  font-size: var(--text-xl);
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.2px;
  line-height: 1.2;
}

.panel-header p,
.section-heading p {
  margin: 5px 0 0;
  color: var(--text-secondary);
  font-size: var(--text-sm);
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-top: var(--sp-4);
}

.form-group label,
.form-label,
.hero-label,
.eyebrow {
  font-size: var(--text-xs);
  font-weight: 700;
  color: var(--text-label);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.eyebrow {
  display: inline-block;
  margin-bottom: 6px;
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--sp-2);
  margin-top: var(--sp-5);
}

.app-input,
.form-control,
.form-select {
  width: 100%;
  background: var(--bg-input);
  border: 1.5px solid var(--border-input);
  border-radius: var(--r-sm);
  padding: 10px 13px;
  font-size: var(--text-base);
  font-family: var(--font-base);
  color: var(--text-primary);
  outline: none;
  transition: border-color var(--t-fast), box-shadow var(--t-fast), background var(--t-fast);
  appearance: none;
  -webkit-appearance: none;
  letter-spacing: 0.01em;
  min-height: 44px;
}

textarea.form-control,
textarea.app-input {
  min-height: 110px;
  resize: vertical;
}

.app-input:hover,
.form-control:hover,
.form-select:hover {
  border-color: var(--border-mid);
  background: var(--bg-surface);
}

.app-input:focus,
.form-control:focus,
.form-select:focus,
.form-check-input:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--clr-petrol-soft);
  background: var(--bg-surface);
}

.app-input::placeholder,
.form-control::placeholder {
  color: var(--text-muted);
}

.password-field {
  position: relative;
}

.password-field .form-control {
  padding-right: 52px;
}

.password-toggle {
  position: absolute;
  top: 50%;
  right: 10px;
  transform: translateY(-50%);
  width: 32px;
  height: 32px;
  border: 1px solid var(--border-light);
  border-radius: var(--r-sm);
  background: var(--bg-surface);
  color: var(--text-secondary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  line-height: 0;
  box-shadow: var(--shadow-sm);
}

.password-toggle:hover {
  color: var(--text-primary);
  border-color: var(--border-mid);
}

.password-toggle svg {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
}

select.app-input,
select.form-select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%2366758f'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 13px center;
  padding-right: 33px;
  cursor: pointer;
}

.autocomplete-group { position: relative; }

.autocomplete-dropdown,
.selection-list {
  background: var(--bg-surface);
  border: 1.5px solid var(--border-mid);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-lg);
  overflow-y: auto;
  animation: dropdownReveal var(--t-fast) var(--ease) both;
}

.autocomplete-dropdown {
  position: absolute;
  top: calc(100% + 5px);
  left: 0;
  right: 0;
  max-height: 220px;
  z-index: 200;
}

.autocomplete-item,
.selection-item {
  display: block;
  width: 100%;
  padding: 10px 13px;
  cursor: pointer;
  font-size: var(--text-base);
  font-family: var(--font-base);
  color: var(--text-primary);
  transition: background var(--t-fast);
  border: none;
  background: transparent;
  text-align: left;
  border-bottom: 1px solid var(--border-light);
}

.autocomplete-item:last-child,
.selection-item:last-child {
  border-bottom: none;
}

.autocomplete-item:hover,
.selection-item:hover {
  background: var(--bg-subtle);
}

.btn-principal,
.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: none;
  border-radius: var(--r-sm);
  padding: 11px 18px;
  font-size: var(--text-sm);
  font-family: var(--font-base);
  font-weight: 700;
  letter-spacing: 0.02em;
  cursor: pointer;
  background: var(--fx-primary-surface);
  color: var(--text-on-dark);
  box-shadow: var(--shadow-btn);
  transition: background var(--t-fast), box-shadow var(--t-fast), transform var(--t-fast);
  white-space: nowrap;
}

.btn-principal:hover:not(:disabled),
.btn-primary:hover:not(:disabled) {
  background: var(--fx-primary-surface-strong);
  transform: translateY(-2px);
}

.btn-principal:disabled,
.btn-primary:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  box-shadow: none;
}

.btn-secundario,
.btn-outline-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1.5px solid var(--border-mid);
  border-radius: var(--r-sm);
  padding: 10px 18px;
  font-size: var(--text-sm);
  font-family: var(--font-base);
  font-weight: 600;
  cursor: pointer;
  background: var(--bg-surface);
  color: var(--text-secondary);
  box-shadow: 0 1px 3px rgba(33, 20, 20, 0.05);
  transition: background var(--t-fast), border-color var(--t-fast), color var(--t-fast), box-shadow var(--t-fast), transform var(--t-fast);
  white-space: nowrap;
}

.btn-secundario:hover,
.btn-outline-secondary:hover {
  background: var(--bg-subtle);
  border-color: var(--border-mid);
  color: var(--text-primary);
  transform: translateY(-1px);
}

.btn-oscuro {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: none;
  border-radius: var(--r-sm);
  padding: 10px 18px;
  font-size: var(--text-sm);
  font-family: var(--font-base);
  font-weight: 700;
  cursor: pointer;
  background: var(--fx-aurora-surface);
  color: var(--text-on-dark);
  box-shadow: 0 2px 6px rgba(27, 23, 23, 0.22), 0 10px 24px rgba(27, 23, 23, 0.2);
  transition: background var(--t-fast), box-shadow var(--t-fast), transform var(--t-fast);
}

.btn-oscuro:hover {
  background: var(--fx-aurora-surface-strong);
  transform: translateY(-1px);
}

.btn-tabla,
.btn.btn-sm {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--r-xs);
  padding: 6px 11px;
  font-size: var(--text-xs);
  font-family: var(--font-base);
  font-weight: 700;
  cursor: pointer;
  transition: opacity var(--t-fast), transform var(--t-fast), box-shadow var(--t-fast);
  white-space: nowrap;
}

.tabla-wrapper,
.table-shell {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  overflow-y: visible;
  border-radius: var(--r-md);
  border: 1px solid var(--border-light);
  box-shadow: var(--shadow-sm);
  background: var(--bg-surface);
  scrollbar-gutter: stable;
  -webkit-overflow-scrolling: touch;
}

.tabla-resumen,
.table-kpis,
.stats-strip {
  display: grid;
  gap: var(--sp-3);
  margin-bottom: var(--sp-4);
}

.mini-card,
.table-kpi-card,
.stat-tile {
  background: var(--bg-subtle);
  border-radius: var(--r-md);
  padding: 12px 18px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 150px;
  border: 1px solid var(--border-light);
}

.mini-card strong,
.table-kpi-card strong,
.stat-tile strong {
  font-size: var(--text-xl);
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.3px;
}

.app-table,
.table-refined {
  width: 100%;
  min-width: max-content;
  border-collapse: collapse;
  font-size: var(--text-sm);
  font-family: var(--font-base);
  margin-bottom: 0;
}

.app-table thead tr,
.table-refined thead tr {
  background: var(--fx-aurora-surface);
}

.app-table th,
.table-refined th {
  padding: 12px 15px;
  text-align: left;
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--text-on-dark-soft);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  white-space: nowrap;
  border-bottom: none;
}

.app-table tbody tr,
.table-refined tbody tr {
  border-bottom: 1px solid var(--border-light);
  transition: background var(--t-fast);
}

.app-table tbody tr:nth-child(even) td,
.table-refined tbody tr:nth-child(even) td {
  background: var(--bg-subtle);
}

.app-table tbody tr:hover td,
.table-refined tbody tr:hover td {
  background: rgba(31, 42, 68, 0.05) !important;
}

.app-table td,
.table-refined td {
  padding: 12px 15px;
  color: var(--text-primary);
  vertical-align: middle;
  background: var(--bg-surface);
  border-color: var(--border-light);
}

.tabla-topbar,
.table-toolbar {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  margin-bottom: var(--sp-4);
  flex-wrap: wrap;
}

.acciones-tabla,
.table-actions {
  display: flex;
  gap: 6px;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
}

.table-action-button {
  width: 86px;
  min-height: 34px;
}

.table-scroll-top {
  display: block;
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  height: 18px;
  margin: 0 0 var(--sp-2);
  padding: 2px;
  border: 1px solid var(--border-light);
  border-radius: var(--r-sm);
  background: var(--bg-subtle);
  box-shadow: inset 0 1px 2px rgba(16, 24, 40, 0.06);
  scrollbar-gutter: stable;
  scrollbar-color: var(--clr-primary) var(--bg-subtle);
  scrollbar-width: thin;
  -webkit-overflow-scrolling: touch;
}

.table-scroll-top > div {
  height: 1px;
}

.table-scroll-top::-webkit-scrollbar,
.refined-table-shell::-webkit-scrollbar,
.table-shell::-webkit-scrollbar {
  height: 12px;
}

.table-scroll-top::-webkit-scrollbar-track,
.refined-table-shell::-webkit-scrollbar-track,
.table-shell::-webkit-scrollbar-track {
  background: var(--bg-subtle);
  border-radius: var(--r-full);
}

.table-scroll-top::-webkit-scrollbar-thumb,
.refined-table-shell::-webkit-scrollbar-thumb,
.table-shell::-webkit-scrollbar-thumb {
  background: var(--clr-primary);
  border: 3px solid var(--bg-subtle);
  border-radius: var(--r-full);
}

.table-scroll-top::-webkit-scrollbar-thumb:hover,
.refined-table-shell::-webkit-scrollbar-thumb:hover,
.table-shell::-webkit-scrollbar-thumb:hover {
  background: var(--clr-primary-dark);
}

.document-link-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-width: 150px;
}

.document-link-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  border: 1px solid var(--border-light);
  border-radius: var(--r-full);
  background: var(--bg-subtle);
  color: var(--text-secondary);
  padding: 4px 9px;
  font-size: var(--text-xs);
  font-weight: 800;
  text-decoration: none;
  white-space: nowrap;
}

.document-link-chip:hover {
  border-color: var(--border-mid);
  color: var(--text-primary);
  background: var(--bg-surface);
}

.document-empty {
  color: var(--text-muted);
  font-size: var(--text-sm);
  white-space: nowrap;
}

.alumnos-admin-table {
  min-width: 1320px;
}

.cuotas-admin-table {
  min-width: 1360px;
}

.sin-resultados,
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--sp-12) var(--sp-5);
  color: var(--text-muted);
  gap: var(--sp-3);
  text-align: center;
}

.loading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--sp-12) var(--sp-5);
  gap: var(--sp-3);
  color: var(--text-muted);
}

.spinner {
  width: 30px;
  height: 30px;
  border: 3px solid var(--border-light);
  border-top-color: var(--clr-primary);
  border-radius: 50%;
  animation: spin 0.65s linear infinite;
}

.alert-error,
.alert-ok,
.feedback-error,
.feedback-success {
  border-radius: var(--r-sm);
  padding: 10px 14px;
  font-size: var(--text-sm);
  font-family: var(--font-base);
  margin-top: var(--sp-3);
  display: flex;
  align-items: center;
  gap: 8px;
  animation: alertPop var(--t-fast) var(--ease) both;
}

.alert-error,
.feedback-error {
  background: #f3ecdf;
  color: #7f6430;
  border: 1px solid #dbc28f;
}

.alert-ok,
.feedback-success {
  background: #f0fdf4;
  color: #166534;
  border: 1px solid #bbf7d0;
}

.validation-message {
  color: #a58948;
  font-size: var(--text-sm);
}

.check-row,
.check-group,
.form-check {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-secondary);
  font-weight: 500;
  font-size: var(--text-base);
}

.check-row input[type="checkbox"],
.check-group input[type="checkbox"],
.form-check-input {
  width: 15px;
  height: 15px;
  accent-color: var(--clr-primary);
  cursor: pointer;
  flex-shrink: 0;
}

.progress-placeholder,
.stub-body {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-3);
  text-align: center;
}

.print-popover-wrap {
  position: relative;
}

.print-popover {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  width: min(720px, calc(100vw - 48px));
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
  padding: var(--sp-4);
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
  z-index: 30;
}

.print-panel-header {
  display: flex;
  justify-content: space-between;
  gap: var(--sp-3);
  padding-bottom: var(--sp-3);
  border-bottom: 1px solid var(--border-light);
}

.print-panel-header h3 {
  margin: 0;
  font-size: var(--text-lg);
  color: var(--text-primary);
}

.print-panel-header p {
  margin: 6px 0 0;
  font-size: var(--text-sm);
  color: var(--text-secondary);
}

.print-close {
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 1.6rem;
  line-height: 1;
  padding: 0;
}

.print-panel-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sp-4);
}

.print-group {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}

.print-group-title {
  font-size: var(--text-sm);
  font-weight: 700;
  color: var(--text-primary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.print-check {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: var(--text-sm);
  color: var(--text-primary);
}

.print-check input {
  accent-color: var(--clr-primary);
}

.print-check.checked {
  opacity: 0.8;
}

.print-hint {
  margin-top: 0.35rem;
  font-size: var(--text-sm);
  color: var(--text-secondary);
}

.print-actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--sp-2);
}

@media (max-width: 720px) {
  .form-panel,
  .tabla-panel,
  .config-panel,
  .panel-card,
  .overview-card,
  .hero-panel,
  .progress-placeholder,
  .quick-link-tile,
  .share-message-box {
    border-radius: var(--r-md);
    padding: var(--sp-4);
  }

  .btn-principal,
  .btn-primary,
  .btn-secundario,
  .btn-outline-secondary,
  .btn-oscuro {
    width: 100%;
    min-height: 42px;
    white-space: normal;
    text-align: center;
  }

  .tabla-wrapper,
  .table-shell,
  .refined-table-shell {
    margin-inline: calc(var(--sp-1) * -1);
    width: calc(100% + (var(--sp-1) * 2));
    max-width: calc(100% + (var(--sp-1) * 2));
    border-radius: var(--r-sm);
  }

  .app-table th,
  .table-refined th,
  .app-table td,
  .table-refined td {
    padding: 10px 12px;
  }

  .acciones-tabla,
  .table-actions {
    justify-content: flex-start;
  }

  .table-action-button {
    width: auto;
    min-width: 74px;
  }

  .print-popover {
    position: fixed;
    left: var(--sp-3);
    right: var(--sp-3);
    top: auto;
    bottom: var(--sp-3);
    width: auto;
    max-height: calc(100vh - 32px);
    overflow: auto;
    border-radius: var(--r-md);
  }

  .print-panel-header,
  .print-panel-grid,
  .print-actions {
    flex-direction: column;
    grid-template-columns: 1fr;
  }
}
