:root {
  --ink: #1d1d1f;
  --graphite: #424245;
  --gray: #6e6e73;
  --gray2: #86868b;
  --line: #e3e3e6;
  --line-strong: #d2d2d7;
  --fog: #f5f5f7;
  --paper: #fbfbfd;
  --blue: #0071e3;
  --blue-dark: #0058b0;
  --green: #34c759;
  --amber: #ff9f0a;
  --red: #ff3b30;
  --radius: 16px;
  --radius-sm: 12px;
  --sidebar-w: 240px;
  --topbar-h: 56px;
  --sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display",
    "Segoe UI", Roboto, "Helvetica Neue", Helvetica, Arial, sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--sans);
  color: var(--ink);
  background: var(--fog);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
.hidden { display: none !important; }

/* ============ LOADING ============ */
.loading {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--fog);
}
.spinner {
  width: 34px; height: 34px;
  border: 3px solid var(--line-strong);
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ============ BUTTONS / FORMS ============ */
.btn {
  font-family: inherit; font-size: 16px; font-weight: 500;
  border: 0; border-radius: 980px; padding: 12px 22px;
  cursor: pointer; transition: background 0.15s, opacity 0.15s, transform 0.1s;
}
.btn:active { transform: scale(0.98); }
.btn-primary { background: var(--blue); color: #fff; }
.btn-primary:hover { background: var(--blue-dark); }
.btn-primary:disabled { background: var(--line-strong); color: var(--gray2); cursor: not-allowed; }
.btn-ghost { background: transparent; color: var(--blue); }
.btn-ghost:hover { background: rgba(0,0,0,0.04); }
.btn-block { width: 100%; }
.btn-danger { color: var(--red); }
.btn-danger:hover { background: rgba(255,59,48,0.08); }
.pill { display: inline-block; font-size: 11px; font-weight: 500; color: var(--gray); background: var(--fog); border: 1px solid var(--line); padding: 2px 8px; border-radius: 980px; }
.pill-off { display: inline-block; font-size: 11px; font-weight: 500; color: #8a6d00; background: #fff6e6; border: 1px solid #ffe0a3; padding: 2px 8px; border-radius: 980px; }
.field select { width: 100%; font-family: inherit; font-size: 16px; padding: 12px 14px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); outline: none; background: #fff; }
.field select:focus { border-color: var(--blue); box-shadow: 0 0 0 4px rgba(0,113,227,0.12); }
.field input[type="file"] { font-size: 14px; padding: 8px 0; }

.field { display: block; margin-bottom: 16px; }
.field > span { display: block; font-size: 13px; color: var(--gray); margin-bottom: 7px; }
.field input {
  width: 100%; font-family: inherit; font-size: 16px;
  padding: 12px 14px; border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm); outline: none; background: #fff;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.field input:focus { border-color: var(--blue); box-shadow: 0 0 0 4px rgba(0,113,227,0.12); }
.form-error {
  background: #fff2f2; border: 1px solid #ffc9c9; color: #c0392b;
  font-size: 14px; border-radius: 10px; padding: 10px 12px; margin-bottom: 14px;
}
.form-ok {
  background: #eafaf0; border: 1px solid #b7e9c9; color: #1e824c;
  font-size: 14px; border-radius: 10px; padding: 10px 12px; margin-bottom: 14px;
}

/* ============ LOGIN ============ */
.login {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  padding: 22px; background: linear-gradient(180deg, #ffffff 0%, #f5f5f7 100%);
}
.login-card {
  width: 100%; max-width: 380px; background: #fff;
  border: 1px solid var(--line); border-radius: 22px; padding: 40px 34px;
  box-shadow: 0 20px 50px rgba(0,0,0,0.06);
}
.login-brand { font-size: 26px; font-weight: 600; letter-spacing: -0.02em; }
.login-sub { color: var(--gray2); font-size: 15px; margin: 2px 0 28px; }
.login-help { text-align: center; font-size: 13px; color: var(--gray2); margin-top: 18px; }
.login-help a { color: var(--blue); }

/* ============ APP SHELL ============ */
.topbar {
  position: sticky; top: 0; z-index: 40; height: var(--topbar-h);
  display: flex; align-items: center; gap: 14px; padding: 0 18px;
  background: rgba(255,255,255,0.8);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--line);
}
.topbar-brand { font-size: 18px; font-weight: 600; letter-spacing: -0.02em; }
.topbar-user { margin-left: auto; }
.user-name { font-size: 14px; color: var(--gray); }
.nav-toggle {
  display: none; flex-direction: column; justify-content: center; gap: 5px;
  width: 30px; height: 30px; background: none; border: 0; cursor: pointer;
}
.nav-toggle span { display: block; width: 20px; height: 1.6px; background: var(--ink); border-radius: 2px; }

.shell { display: flex; min-height: calc(100vh - var(--topbar-h)); }
.sidebar {
  width: var(--sidebar-w); flex-shrink: 0; background: #fff;
  border-right: 1px solid var(--line); padding: 18px 14px;
  display: flex; flex-direction: column;
  position: sticky; top: var(--topbar-h); height: calc(100vh - var(--topbar-h));
}
.nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav-item {
  font-size: 15px; color: var(--graphite); padding: 10px 14px;
  border-radius: 10px; transition: background 0.15s, color 0.15s;
}
.nav-item:hover { background: var(--fog); }
.nav-item.active { background: #eef5ff; color: var(--blue); font-weight: 500; }
.logout { margin-top: 10px; align-self: flex-start; }

.backdrop { position: fixed; inset: 0; z-index: 30; background: rgba(0,0,0,0.3); }

.content {
  flex: 1; padding: 40px; max-width: 900px; outline: none;
}

/* ============ CONTENT BLOCKS ============ */
.page-eyebrow { font-size: 13px; font-weight: 600; color: var(--blue); margin-bottom: 10px; }
.page-title { font-size: clamp(28px, 4vw, 38px); font-weight: 600; letter-spacing: -0.02em; line-height: 1.1; }
.page-lead { font-size: 18px; color: var(--gray); margin-top: 12px; max-width: 60ch; }
.section-gap { margin-top: 40px; }

.card {
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  padding: 24px;
}
.card + .card { margin-top: 16px; }
.card-title { font-size: 18px; font-weight: 600; letter-spacing: -0.01em; margin-bottom: 6px; }
.card-text { color: var(--gray); font-size: 15px; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; }

/* Academia (LMS member) */
.video-embed { position: relative; width: 100%; aspect-ratio: 16 / 9; border-radius: var(--radius); overflow: hidden; background: #000; }
.video-embed iframe, .video-embed video { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.mod-card, .lesson-row { width: 100%; text-align: left; cursor: pointer; font-family: inherit; margin-bottom: 12px; transition: border-color .15s, transform .1s; }
.mod-card:hover, .lesson-row:hover { border-color: var(--line-strong); }
.mod-card:active, .lesson-row:active { transform: scale(.995); }
.mod-go { color: var(--blue); font-size: 14px; margin-top: 10px; }
.lesson-row { display: flex; align-items: center; gap: 14px; }
.lesson-row .mod-go { margin: 0 0 0 auto; }
.lesson-check { width: 22px; height: 22px; border-radius: 50%; border: 1.6px solid var(--line-strong); flex-shrink: 0; display: flex; align-items: center; justify-content: center; }
.lesson-check.done { background: var(--green); border-color: var(--green); }
.lesson-check.done::after { content: ""; width: 5px; height: 10px; border: solid #fff; border-width: 0 2px 2px 0; transform: rotate(45deg) translateY(-1px); }

.muted-note {
  border: 1px dashed var(--line-strong); border-radius: var(--radius);
  padding: 32px 24px; text-align: center; color: var(--gray2); background: var(--paper);
}

/* Estado de membresía */
.status-banner {
  border-radius: var(--radius); padding: 20px 24px; display: flex;
  align-items: center; gap: 14px; flex-wrap: wrap;
}
.status-dot { width: 12px; height: 12px; border-radius: 50%; flex-shrink: 0; }
.status-green { background: #eafaf0; border: 1px solid #b7e9c9; }
.status-green .status-dot { background: var(--green); }
.status-amber { background: #fff6e6; border: 1px solid #ffe0a3; }
.status-amber .status-dot { background: var(--amber); }
.status-red { background: #fff2f2; border: 1px solid #ffc9c9; }
.status-red .status-dot { background: var(--red); }
.status-neutral { background: var(--fog); border: 1px solid var(--line-strong); }
.status-neutral .status-dot { background: var(--gray2); }
.status-text { font-size: 15px; }
.status-text strong { font-weight: 600; }
.status-cta { margin-left: auto; }

/* Checklist Comenzar */
.checklist { list-style: none; }
.check-item {
  display: flex; gap: 14px; align-items: flex-start; padding: 16px 0;
  border-top: 1px solid var(--line);
}
.check-item:first-child { border-top: 0; }
.check-box {
  width: 24px; height: 24px; border-radius: 50%; border: 1.6px solid var(--line-strong);
  flex-shrink: 0; cursor: pointer; display: flex; align-items: center; justify-content: center;
  background: #fff; transition: background 0.15s, border-color 0.15s;
}
.check-box.done { background: var(--blue); border-color: var(--blue); }
.check-box.done::after { content: ""; width: 6px; height: 11px; border: solid #fff; border-width: 0 2px 2px 0; transform: rotate(45deg) translateY(-1px); }
.check-body h4 { font-size: 16px; font-weight: 600; }
.check-body p { color: var(--gray); font-size: 14px; margin-top: 2px; }
.check-body a { color: var(--blue); font-size: 14px; }

/* ============ RESPONSIVE ============ */
@media (max-width: 820px) {
  .nav-toggle { display: flex; }
  .content { padding: 24px 18px; }
  .sidebar {
    position: fixed; top: 0; left: 0; height: 100vh; z-index: 35;
    transform: translateX(-100%); transition: transform 0.25s ease;
    box-shadow: 0 0 40px rgba(0,0,0,0.15);
  }
  .sidebar.open { transform: translateX(0); }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation-duration: 0.01ms !important; }
}
