*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #f4f6f9;
  color: #1e293b;
  min-height: 100vh;
}

/* ---- Layout ---- */
.app-layout { display: flex; min-height: 100vh; }

/* ---- Sidebar ---- */
.sidebar {
  width: 230px;
  background: #0f172a;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  transition: transform 0.3s ease;
}
.sidebar-logo {
  padding: 22px 18px 18px;
  border-bottom: 1px solid rgba(255,255,255,0.07);
  display: flex; align-items: center; gap: 12px;
}
.logo-icon {
  width: 38px; height: 38px; background: #e11d48;
  border-radius: 10px; display: flex;
  align-items: center; justify-content: center;
  font-size: 20px; flex-shrink: 0;
}
.logo-text { color: white; font-weight: 700; font-size: 15px; line-height: 1.2; }
.logo-sub  { color: rgba(255,255,255,0.35); font-size: 11px; margin-top: 2px; }

.sidebar-nav { padding: 12px 10px; flex: 1; overflow-y: auto; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: 8px;
  color: rgba(255,255,255,0.55); font-size: 13px;
  text-decoration: none; margin-bottom: 2px;
  transition: background 0.15s, color 0.15s;
}
.nav-item:hover  { background: rgba(255,255,255,0.07); color: white; }
.nav-item.activo { background: rgba(255,255,255,0.12); color: white; font-weight: 600; }
.nav-item .nav-icon { font-size: 16px; width: 20px; text-align: center; }
.nav-section {
  font-size: 10px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 1px; color: rgba(255,255,255,0.25);
  padding: 14px 12px 6px;
}

.sidebar-user {
  padding: 14px 16px;
  border-top: 1px solid rgba(255,255,255,0.07);
  display: flex; align-items: center; gap: 10px;
}
.user-avatar {
  width: 32px; height: 32px; background: #e11d48;
  border-radius: 50%; display: flex; align-items: center;
  justify-content: center; color: white; font-weight: 700;
  font-size: 13px; flex-shrink: 0;
}
.user-name { color: white; font-size: 13px; font-weight: 600; }
.user-role { color: rgba(255,255,255,0.35); font-size: 11px; }

/* ---- Contenido principal ---- */
.main-content {
  margin-left: 230px;
  flex: 1; display: flex;
  flex-direction: column; min-height: 100vh;
}
.topbar {
  background: white;
  border-bottom: 1px solid #e2e8f0;
  padding: 14px 28px;
  display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; z-index: 50;
}
.topbar-title { font-size: 18px; font-weight: 700; color: #0f172a; }
.topbar-sub   { font-size: 13px; color: #64748b; margin-top: 2px; }
.topbar-actions { display: flex; gap: 10px; align-items: center; }
.page-content { padding: 24px 28px; flex: 1; }

/* ---- Cards ---- */
.card {
  background: white; border-radius: 12px;
  border: 1px solid #e2e8f0; padding: 20px; margin-bottom: 20px;
}
.card-header {
  display: flex; justify-content: space-between;
  align-items: center; margin-bottom: 16px;
}
.card-title { font-size: 14px; font-weight: 700; color: #0f172a; }
.card-link  { font-size: 12px; color: #e11d48; text-decoration: none; font-weight: 600; }

/* ---- Stats ---- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 14px; margin-bottom: 24px;
}
.stat-card {
  background: white; border-radius: 12px;
  border: 1px solid #e2e8f0; padding: 18px 16px;
}
.stat-label { font-size: 11px; color: #64748b; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; }
.stat-value { font-size: 32px; font-weight: 700; color: #0f172a; line-height: 1; margin: 6px 0 4px; }
.stat-trend { font-size: 12px; }
.trend-up   { color: #16a34a; }
.trend-down { color: #dc2626; }
.trend-flat { color: #64748b; }

/* ---- Tablas ---- */
.tabla-wrap { overflow-x: auto; }
.tabla { width: 100%; border-collapse: collapse; font-size: 13px; }
.tabla thead th {
  text-align: left; padding: 8px 12px;
  color: #64748b; font-weight: 600; font-size: 12px;
  text-transform: uppercase; letter-spacing: 0.5px;
  border-bottom: 1px solid #f1f5f9; white-space: nowrap;
}
.tabla tbody td {
  padding: 10px 12px; border-bottom: 1px solid #f8fafc;
  color: #1e293b; vertical-align: middle;
}
.tabla tbody tr:last-child td { border-bottom: none; }
.tabla tbody tr:hover td      { background: #f8fafc; }

/* ---- Badges ---- */
.badge {
  display: inline-block; padding: 3px 10px;
  border-radius: 20px; font-size: 11px; font-weight: 600;
}
.badge-blanco   { background: #f1f5f9; color: #475569; }
.badge-amarillo { background: #fef9c3; color: #854d0e; }
.badge-naranja  { background: #fff7ed; color: #9a3412; }
.badge-verde    { background: #dcfce7; color: #166534; }
.badge-azul     { background: #dbeafe; color: #1e40af; }
.badge-marron   { background: #fef3c7; color: #78350f; }
.badge-negro    { background: #1e293b; color: #f8fafc; }
.badge-ok       { background: #dcfce7; color: #166534; }
.badge-no       { background: #fee2e2; color: #991b1b; }

/* ---- Botones ---- */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 9px 18px; border-radius: 8px; font-size: 13px;
  font-weight: 600; cursor: pointer; text-decoration: none;
  border: none; transition: opacity 0.15s;
}
.btn:hover    { opacity: 0.88; }
.btn-primary  { background: #e11d48; color: white; }
.btn-dark     { background: #0f172a; color: white; }
.btn-outline  { background: white; color: #0f172a; border: 1.5px solid #e2e8f0; }
.btn-sm       { padding: 6px 14px; font-size: 12px; }

/* ---- Formularios ---- */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-group { margin-bottom: 16px; }
.form-label {
  display: block; font-size: 12px; font-weight: 600;
  color: #64748b; text-transform: uppercase;
  letter-spacing: 0.5px; margin-bottom: 6px;
}
.form-control {
  width: 100%; padding: 10px 14px;
  border: 1.5px solid #e2e8f0; border-radius: 8px;
  font-size: 14px; color: #1e293b;
  background: white; transition: border-color 0.2s;
}
.form-control:focus { outline: none; border-color: #e11d48; }
.errorlist { list-style: none; color: #dc2626; font-size: 12px; margin-top: 4px; }

/* ---- Alertas ---- */
.alert { padding: 12px 16px; border-radius: 8px; font-size: 13px; margin-bottom: 16px; }
.alert-success { background: #dcfce7; color: #166534; border: 1px solid #bbf7d0; }
.alert-error   { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }

/* ---- Overlay móvil ---- */
.sidebar-overlay {
  display: none; position: fixed;
  inset: 0; background: rgba(0,0,0,0.5); z-index: 99;
}
.sidebar-overlay.visible { display: block; }
.hamburger {
  display: none; background: none; border: none;
  font-size: 22px; cursor: pointer; color: #0f172a;
}

/* ---- Perfil público ---- */
.perfil-header {
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
  color: white; padding: 32px 20px 40px; text-align: center;
}
.perfil-avatar {
  width: 90px; height: 90px; border-radius: 50%;
  border: 3px solid rgba(255,255,255,0.3);
  margin: 0 auto 14px; overflow: hidden;
  background: #e11d48; display: flex;
  align-items: center; justify-content: center;
  font-size: 32px; font-weight: 700; color: white;
}
.perfil-nombre { font-size: 22px; font-weight: 700; }
.perfil-rango {
  display: inline-block; background: rgba(255,255,255,0.15);
  padding: 5px 16px; border-radius: 20px;
  font-size: 13px; margin-top: 8px;
}
.perfil-body { max-width: 500px; margin: -20px auto 0; padding: 0 16px 32px; }

/* ---- Form card header ---- */
.form-card-header {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 20px; padding-bottom: 16px;
  border-bottom: 1px solid #f1f5f9;
}
.form-card-avatar {
  width: 42px; height: 42px; background: #0f172a;
  border-radius: 50%; display: flex; align-items: center;
  justify-content: center; color: white; font-weight: 700;
  flex-shrink: 0;
}
.form-card-nombre { font-weight: 700; font-size: 14px; }
.form-card-rango  { font-size: 12px; color: #64748b; }
.form-actions { display: flex; gap: 10px; margin-top: 8px; }
.form-actions .btn { flex: 1; justify-content: center; }
.form-wrapper { max-width: 600px; }

/* ---- Detalle estudiante ---- */
.detalle-grid {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 20px; align-items: start;
}
.perfil-card { text-align: center; padding: 28px 20px; }
.perfil-card-foto {
  width: 90px; height: 90px; border-radius: 50%;
  object-fit: cover; border: 3px solid #e2e8f0;
  margin-bottom: 14px; display: block;
  margin-left: auto; margin-right: auto;
}
.perfil-card-iniciales {
  width: 90px; height: 90px; background: #0f172a;
  border-radius: 50%; display: flex; align-items: center;
  justify-content: center; color: white; font-size: 30px;
  font-weight: 700; margin: 0 auto 14px;
}
.perfil-card-nombre  { font-size: 17px; font-weight: 700; margin-bottom: 4px; }
.perfil-card-cedula  { font-size: 12px; color: #64748b; margin-bottom: 12px; }
.perfil-card-cinturon { margin-top: 16px; font-size: 12px; color: #64748b; }

.datos-fila {
  display: flex; justify-content: space-between;
  padding: 7px 0; border-bottom: 1px solid #f8fafc; font-size: 13px;
}
.datos-fila:last-child { border-bottom: none; }
.datos-label    { color: #64748b; }
.datos-valor    { font-weight: 500; }
.datos-valor-sm { font-weight: 500; font-size: 12px; }

.qr-card     { text-align: center; }
.qr-card-img {
  width: 160px; height: 160px;
  border-radius: 8px; border: 1px solid #e2e8f0;
  display: block; margin: 0 auto;
}
.qr-card-label { font-size: 11px; color: #94a3b8; margin-top: 8px; }

.nota-ok  { font-weight: 700; color: #16a34a; }
.nota-mal { font-weight: 700; color: #dc2626; }
.td-fecha { color: #64748b; }
.td-small { font-size: 12px; }
.td-bold  { font-weight: 600; }
.td-center-empty { text-align: center; color: #94a3b8; padding: 20px; }

/* ---- Formulario estudiante ---- */
.form-wrapper-lg { max-width: 700px; }
.form-seccion {
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.8px; color: #94a3b8; margin-bottom: 12px;
}
.form-seccion-mt { margin-top: 20px; }
.form-activo {
  display: flex; align-items: center; gap: 10px;
  margin: 16px 0 24px; padding: 14px;
  background: #f8fafc; border-radius: 8px;
}
.form-activo label { font-size: 14px; font-weight: 500; cursor: pointer; }
.form-botones { display: flex; gap: 10px; }
.form-botones .btn { flex: 1; justify-content: center; }

/* ============================
   RESPONSIVE
   ============================ */
@media (max-width: 900px) {
  .detalle-grid { grid-template-columns: 1fr; }
  .detalle-grid > div:first-child {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
  }
  .detalle-grid > div:first-child > .perfil-card { grid-column: span 2; }
  .qr-card { display: none; }
}

@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.abierto { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .hamburger { display: block; }
  .page-content { padding: 16px; }
  .topbar { padding: 12px 16px; }
  .form-grid { grid-template-columns: 1fr; }

  .topbar-actions { gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
  .topbar-actions .btn-sm { padding: 5px 8px; font-size: 11px; }

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

  /* Tablas como tarjetas en móvil */
  .tabla thead { display: none; }
  .tabla tbody tr {
    display: block;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    margin-bottom: 10px;
    padding: 8px 12px;
  }
  .tabla tbody td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #f8fafc;
    padding: 6px 0;
    font-size: 13px;
  }
  .tabla tbody td:last-child { border-bottom: none; }
  .tabla tbody td::before {
    content: attr(data-label);
    font-weight: 600;
    color: #64748b;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    margin-right: 8px;
    flex-shrink: 0;
  }
  .tabla tbody tr:last-child td { border-bottom: none; }
  .tabla tbody tr:hover td { background: transparent; }

  .form-wrapper-lg { max-width: 100%; }
  .form-botones { flex-direction: column; }
  .form-wrapper { max-width: 100%; }
}

@media (max-width: 500px) {
  .detalle-grid > div:first-child { grid-template-columns: 1fr; }
  .detalle-grid > div:first-child > .perfil-card { grid-column: span 1; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .topbar-title { font-size: 15px; }
  .stat-value   { font-size: 26px; }
}
