:root {
  --bg: #f4f6fb;
  --card: #ffffff;
  --ink: #0f172a;
  --mut: #64748b;
  --line: #e2e8f0;
  --pri: #1e3a8a;       /* Azul Marino Académico */
  --pri2: #172554;
  --priS: #eff6ff;
  --acc: #d97706;       /* Dorado / Ámbar Excelencia */
  --accS: #fef3c7;
  --ok: #059669;
  --okbg: #d1fae5;
  --err: #dc2626;
  --errbg: #fee2e2;
  --warn: #b45309;
  --warnbg: #fef3c7;
  --side: #0f172a;
  --side2: #090d16;
  --sh: 0 4px 6px -1px rgba(15, 23, 42, .05), 0 10px 24px -4px rgba(15, 23, 42, .07);
  --r: 16px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1120;
    --card: #131c31;
    --ink: #f1f5f9;
    --mut: #94a3b8;
    --line: #1e293b;
    --pri: #60a5fa;
    --pri2: #93c5fd;
    --priS: #172554;
    --acc: #fbbf24;
    --accS: #451a03;
    --ok: #34d399;
    --okbg: #064e3b;
    --err: #f87171;
    --errbg: #450a0a;
    --warn: #fbbf24;
    --warnbg: #451a03;
    --side: #070b14;
    --side2: #04060c;
  }
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.6 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
}
a { color: var(--pri); text-decoration: none; }
a:hover { text-decoration: underline; }
.wrap { max-width: 1180px; margin: 0 auto; padding: 0 22px; }
h1 { font-size: 28px; font-weight: 800; margin: 0 0 6px; letter-spacing: -.4px; }
h2 { font-size: 20px; font-weight: 700; margin: 28px 0 12px; }
h3 { font-size: 16px; font-weight: 700; margin: 0 0 8px; }
.sub { color: var(--mut); margin: 0 0 20px; }
main.wrap { padding-top: 28px; padding-bottom: 48px; min-height: 75vh; width: 100%; }

/* Layout Principal con Barra Lateral */
.app { display: flex; min-height: 100vh; }
.side {
  width: 270px;
  flex: none;
  background: linear-gradient(180deg, var(--side) 0%, var(--side2) 100%);
  color: #cbd5e1;
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 20px 14px;
  z-index: 30;
  border-right: 1px solid rgba(255,255,255,.06);
}
.logo {
  display: flex;
  gap: 12px;
  align-items: center;
  color: #fff;
  padding: 4px 8px 18px;
  border-bottom: 1px solid rgba(255,255,255,.08);
  margin-bottom: 16px;
}
.logo:hover { text-decoration: none; }
.logo b { display: block; font-size: 15px; line-height: 1.2; letter-spacing: -.2px; }
.logo small { display: block; color: #fbbf24; font-size: 11px; font-weight: 600; margin-top: 2px; text-transform: uppercase; letter-spacing: .5px; }
.logo-i {
  width: 44px; height: 44px; border-radius: 12px;
  background: linear-gradient(135deg, #2563eb, #d97706);
  display: flex; align-items: center; justify-content: center;
  color: #fff; flex: none; box-shadow: 0 4px 12px rgba(37,99,235,.35);
}
.menu { display: flex; flex-direction: column; gap: 4px; flex: 1; overflow-y: auto; }
.menu-t { font-size: 10px; font-weight: 700; letter-spacing: 1.4px; text-transform: uppercase; color: #64748b; padding: 10px 12px 4px; }
.menu a {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 13px; border-radius: 12px;
  color: #cbd5e1; font-weight: 500; transition: all .15s ease;
}
.menu a:hover { background: rgba(255,255,255,.07); text-decoration: none; color: #fff; }
.menu a.on {
  background: linear-gradient(90deg, #1d4ed8, #2563eb);
  color: #fff; font-weight: 600;
  box-shadow: 0 4px 14px rgba(37,99,235,.4);
}
.side-user {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 8px 2px; border-top: 1px solid rgba(255,255,255,.08);
}
.avatar {
  width: 38px; height: 38px; border-radius: 50%;
  background: linear-gradient(135deg, #d97706, #b45309);
  color: #fff; font-weight: 800; display: flex; align-items: center; justify-content: center; flex: none;
}
.who { min-width: 0; flex: 1; }
.who b { display: block; color: #fff; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.who small { color: #94a3b8; font-size: 11px; }

/* Tarjetas, Grids y Badges */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 20px;
  box-shadow: var(--sh);
  margin-bottom: 16px;
}
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 18px; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; margin-bottom: 22px; }
.kpi {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--r);
  padding: 18px; box-shadow: var(--sh); position: relative; overflow: hidden;
}
.kpi .n { display: block; font-size: 28px; font-weight: 800; color: var(--pri); line-height: 1.1; }
.kpi .lbl { font-size: 12px; color: var(--mut); font-weight: 600; text-transform: uppercase; letter-spacing: .4px; }

/* Hero Pre-Universitario */
.hero {
  background: linear-gradient(135deg, #0f172a 0%, #1e3a8a 58%, #1d4ed8 100%);
  color: #fff; border-radius: 22px; padding: 48px 32px; text-align: center;
  box-shadow: 0 20px 40px -15px rgba(15, 23, 42, .35); position: relative; overflow: hidden;
}
.hero h1 { font-size: 36px; color: #fff; margin-bottom: 10px; }
.hero p { color: #dbeafe; max-width: 680px; margin: 0 auto 24px; font-size: 16px; }

/* Chips y Medallas Ranking */
.chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600;
  background: var(--priS); color: var(--pri); border: 1px solid transparent;
}
.chip.ok { background: var(--okbg); color: var(--ok); }
.chip.err { background: var(--errbg); color: var(--err); }
.chip.warn { background: var(--warnbg); color: var(--warn); }
.chip.gold { background: #fef3c7; color: #92400e; border-color: #f59e0b; }

.rank-pos {
  display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; border-radius: 50%; font-weight: 800; font-size: 13px;
  background: var(--bg); color: var(--ink);
}
.rank-1 { background: linear-gradient(135deg, #fbbf24, #d97706); color: #fff; }
.rank-2 { background: linear-gradient(135deg, #cbd5e1, #64748b); color: #fff; }
.rank-3 { background: linear-gradient(135deg, #d97706, #92400e); color: #fff; }

/* Botones y Formularios */
.btn, button {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  background: var(--pri); color: #fff; border: 0; border-radius: 11px;
  padding: 10px 18px; font: 600 14px/1.2 inherit; cursor: pointer; transition: .15s;
}
.btn:hover, button:hover { background: var(--pri2); text-decoration: none; transform: translateY(-1px); }
.btn.sec, button.sec { background: var(--card); color: var(--ink); border: 1px solid var(--line); }
.btn.acc { background: var(--acc); color: #fff; }
.btn.sm, button.sm { padding: 6px 12px; font-size: 13px; border-radius: 9px; }

input, select, textarea {
  width: 100%; padding: 10px 13px; border-radius: 11px;
  border: 1px solid var(--line); background: var(--card); color: var(--ink);
  font: inherit; margin-top: 4px;
}
label { display: block; font-weight: 600; font-size: 13px; margin-top: 12px; color: var(--ink); }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.between { justify-content: space-between; }
.scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; background: var(--card); border-radius: var(--r); overflow: hidden; }
th, td { padding: 12px 14px; border-bottom: 1px solid var(--line); text-align: left; }
th { background: var(--priS); color: var(--pri); font-size: 12px; text-transform: uppercase; letter-spacing: .5px; }