:root {
  --bg: #f3f1ec;
  --surface: #ffffff;
  --surface-2: #f8f5ef;
  --surface-3: #171a23;
  --border: #ded6c9;
  --text: #1e2432;
  --muted: #6d7483;
  --accent: #8b5cf6;
  --accent-strong: #8b5cf6;
  --success: #20b26b;
  --danger: #cf4f56;
  --shadow: 0 24px 60px rgba(26, 30, 40, 0.12);
  --radius: 18px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: Manrope, "Segoe UI", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(139, 92, 246, 0.14), transparent 28%),
    linear-gradient(180deg, #f5f1e9 0%, #f1ede6 100%);
}

button,
input,
select,
video {
  font: inherit;
}

a {
  color: inherit;
}

.eyebrow {
  margin: 0;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-card {
  width: min(100%, 460px);
  background: rgba(255, 255, 255, 0.84);
  backdrop-filter: blur(18px);
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: 28px;
  padding: 32px;
  box-shadow: var(--shadow);
}

.login-card h1 {
  margin: 8px 0 10px;
  font-size: clamp(2rem, 4vw, 2.6rem);
  line-height: 1.05;
}

.login-kicker {
  margin: 0;
  color: var(--accent-strong);
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.login-copy {
  margin: 0 0 24px;
  color: var(--muted);
  line-height: 1.6;
}

.login-help {
  margin: -2px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.login-form {
  display: grid;
  gap: 16px;
}

.login-form label {
  display: grid;
  gap: 8px;
}

.login-form span {
  font-size: 14px;
  font-weight: 700;
}

.login-form input {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px 16px;
  background: #fffdfa;
}

.login-form button,
.nav-btn,
.action-btn,
.icon-btn {
  border: 0;
  border-radius: 14px;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.login-form button,
.nav-btn,
.action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 0 18px;
  text-decoration: none;
  font-weight: 800;
  cursor: pointer;
}

.login-form button,
.nav-btn,
.action-btn:not(.secondary) {
  color: #fff;
  background: linear-gradient(135deg, var(--accent-strong), #6d6af8);
  box-shadow: 0 16px 30px rgba(109, 106, 248, 0.28);
}

.nav-btn.secondary,
.action-btn.secondary {
  color: var(--text);
  background: #fff;
  border: 1px solid var(--border);
  box-shadow: none;
}

.login-form button:hover,
.nav-btn:hover,
.action-btn:hover,
.icon-btn:hover,
.course-select:hover,
.lesson-link:hover,
.module-toggle:hover {
  transform: translateY(-1px);
}

.login-error {
  display: none;
  margin: 0;
  color: var(--danger);
  font-size: 14px;
  font-weight: 700;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 360px 1fr;
}

.course-sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  padding: 26px 20px 28px;
  background: rgba(255, 251, 245, 0.9);
  border-right: 1px solid var(--border);
  backdrop-filter: blur(18px);
}

.sidebar-head h2 {
  margin: 8px 0 10px;
  font-size: 1.8rem;
  line-height: 1.1;
}

.sidebar-description {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.progress-panel {
  margin-top: 22px;
  padding: 16px;
  border-radius: 18px;
  background: var(--surface);
  border: 1px solid var(--border);
}

.progress-copy {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 14px;
}

.progress-copy strong {
  font-size: 14px;
}

.progress-bar {
  margin-top: 10px;
  height: 10px;
  border-radius: 999px;
  background: #ece4d8;
  overflow: hidden;
}

.progress-bar span {
  display: block;
  width: 0;
  height: 100%;
  background: linear-gradient(90deg, var(--accent-strong), #69a8ff);
  border-radius: inherit;
}

.module-list {
  margin-top: 20px;
  display: grid;
  gap: 14px;
}

.module {
  border: 1px solid var(--border);
  border-radius: 18px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.72);
}

.module-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 0;
  background: transparent;
  padding: 16px 18px;
  font-weight: 800;
  text-align: left;
  cursor: pointer;
}

.module-count {
  min-width: 28px;
  height: 28px;
  display: inline-grid;
  place-items: center;
  border-radius: 999px;
  background: #eee6db;
  color: var(--muted);
  font-size: 12px;
}

.lesson-list {
  display: grid;
  gap: 2px;
  padding: 0 10px 10px;
}

.lesson-link {
  width: 100%;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  border: 0;
  border-radius: 14px;
  background: transparent;
  padding: 12px;
  text-align: left;
  cursor: pointer;
}

.lesson-link.active {
  background: #fff;
  box-shadow: inset 0 0 0 1px rgba(139, 92, 246, 0.18);
}

.lesson-status {
  width: 14px;
  height: 14px;
  border-radius: 999px;
  margin-top: 4px;
  border: 2px solid var(--accent-strong);
  flex: 0 0 auto;
}

.lesson-status.done {
  background: var(--accent-strong);
  box-shadow: inset 0 0 0 2px #fff;
}

.lesson-copy {
  display: grid;
  gap: 4px;
}

.lesson-name {
  font-size: 14px;
  font-weight: 700;
  line-height: 1.4;
}

.lesson-duration {
  font-size: 12px;
  color: var(--muted);
}

.course-main {
  min-width: 0;
  padding: 24px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 20px;
  border-radius: 24px;
  background: rgba(18, 22, 31, 0.92);
  color: #fff;
  box-shadow: var(--shadow);
}

.topbar-left,
.topbar-right,
.topbar-controls {
  display: flex;
  align-items: center;
  gap: 14px;
}

.admin-btn {
  min-width: 104px;
}

.icon-btn {
  width: 46px;
  height: 46px;
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  cursor: pointer;
}

.course-select {
  min-width: 240px;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  padding: 12px 14px;
  cursor: pointer;
}

.course-select option {
  color: #111;
}

.user-pill {
  padding: 10px 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.9);
  font-size: 14px;
}

.lesson-shell {
  margin-top: 22px;
  border-radius: 30px;
  padding: clamp(22px, 4vw, 38px);
  background: rgba(255, 255, 255, 0.8);
  box-shadow: var(--shadow);
}

.security-panel,
.admin-panel {
  margin-top: 22px;
  border-radius: 24px;
  padding: 20px;
  background: rgba(255, 255, 255, 0.82);
  box-shadow: var(--shadow);
}

.security-copy {
  margin: 8px 0 0;
  color: var(--muted);
}

.password-form,
.admin-user-form {
  margin-top: 18px;
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

.password-form {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.password-form input,
.admin-user-form input,
.admin-user-form select {
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 0 14px;
  background: #fffdfa;
}

.inline-message {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.admin-head h2 {
  margin: 8px 0 0;
}

.admin-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
}

.admin-export-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.metrics-grid {
  margin-top: 18px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}

.metric-card {
  padding: 16px;
  border-radius: 18px;
  background: #fffdfa;
  border: 1px solid var(--border);
  display: grid;
  gap: 6px;
}

.metric-card span {
  color: var(--muted);
  font-size: 13px;
}

.metric-card strong {
  font-size: 1.6rem;
}

.metric-wide {
  grid-column: 1 / -1;
}

.recent-logins {
  display: grid;
  gap: 4px;
}

.recent-logins p {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin: 0;
  font-size: 12px;
  line-height: 1.25;
}

.recent-logins strong {
  font-size: 12px;
  font-weight: 700;
}

.recent-logins span {
  color: var(--muted);
  font-size: 11px;
  white-space: nowrap;
}

.recent-logins-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 4px;
}

.text-btn {
  border: 0;
  background: transparent;
  padding: 0;
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
}

.history-modal {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(18, 22, 31, 0.35);
  z-index: 40;
}

.history-modal[hidden] {
  display: none;
}

.history-dialog {
  width: min(100%, 760px);
  max-height: min(80vh, 760px);
  overflow: hidden;
  border-radius: 24px;
  background: #fffdfa;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  display: grid;
  grid-template-rows: auto 1fr;
}

.history-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 20px 14px;
  border-bottom: 1px solid #ece4d8;
}

.history-head h3 {
  margin: 8px 0 0;
}

.history-list {
  overflow: auto;
  display: grid;
  gap: 6px;
  padding: 16px 20px 20px;
}

.action-dialog {
  max-width: 560px;
}

.action-body {
  display: grid;
  gap: 14px;
  padding: 18px 20px 20px;
}

.action-body input {
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 0 14px;
  background: #fffdfa;
}

.history-item {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 10px;
  border-radius: 14px;
  background: #ffffff;
  border: 1px solid #ece4d8;
  font-size: 13px;
  line-height: 1.25;
}

.history-item strong {
  font-size: 13px;
}

.history-item span {
  color: var(--muted);
  white-space: nowrap;
}

.admin-filters {
  margin-top: 18px;
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr;
  gap: 12px;
}

.admin-filters input,
.admin-filters select {
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 0 14px;
  background: #fffdfa;
}

.new-user-panel {
  margin-top: 18px;
  padding: 18px;
  border-radius: 22px;
  background: #fffdfa;
  border: 1px solid var(--border);
}

.new-user-head h3 {
  margin: 8px 0 0;
}

.admin-users-list {
  margin-top: 18px;
  display: grid;
  gap: 12px;
}

.admin-user-card {
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: 22px;
  background: #fffdfa;
}

.admin-user-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.admin-user-summary {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr) minmax(0, 1fr) auto;
  gap: 16px;
  align-items: center;
}

.admin-user-primary {
  display: grid;
  gap: 6px;
}

.admin-user-primary strong {
  font-size: 1.05rem;
}

.admin-user-email {
  font-size: 0.95rem;
}

.admin-user-stats {
  display: grid;
  gap: 4px;
}

.admin-user-progress {
  display: grid;
  gap: 8px;
}

.progress-course {
  display: grid;
  gap: 4px;
}

.progress-course-head {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 13px;
  color: var(--muted);
}

.tiny-progress {
  height: 8px;
  border-radius: 999px;
  background: #ece4d8;
  overflow: hidden;
}

.tiny-progress span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--accent-strong), #69a8ff);
}

.user-summary-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

.expand-btn {
  min-height: 42px;
  padding: 0 14px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: #fff;
  cursor: pointer;
  font-weight: 700;
}

.admin-user-detail {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid #ece4d8;
  display: grid;
  gap: 16px;
}

.detail-grid {
  display: grid;
  grid-template-columns: 1.1fr 1fr;
  gap: 16px;
}

.detail-card {
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: #ffffff;
}

.detail-card h4 {
  margin: 0 0 10px;
}

.edit-user-form {
  display: grid;
  gap: 10px;
}

.edit-user-form input,
.edit-user-form select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0 12px;
  background: #fffdfa;
}

.role-pill {
  align-self: center;
  padding: 8px 12px;
  border-radius: 999px;
  background: #eee6db;
  color: var(--text);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.role-pill.inactive {
  background: #f3dada;
}

.status-stack {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.admin-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-start;
  gap: 8px;
}

.course-picker,
.course-inline-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: flex-start;
}

.course-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: #fffdfa;
  cursor: pointer;
  font-size: 13px;
}

.course-pill input {
  margin: 0;
}

.admin-user-form {
  grid-template-columns: repeat(6, minmax(0, 1fr));
}

.danger-zone {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.mini-btn {
  min-height: 38px;
  padding: 0 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  font-weight: 700;
  cursor: pointer;
}

.mini-btn.danger {
  border-color: #e3b5b5;
  color: #a33a40;
}

.lesson-header h1 {
  margin: 10px 0 8px;
  font-size: clamp(2rem, 4vw, 3rem);
  line-height: 1.04;
}

.lesson-meta {
  margin: 0;
  color: var(--muted);
}

.video-wrap {
  margin-top: 24px;
  max-width: 960px;
}

.video-wrap video,
.video-fallback {
  width: 100%;
  border-radius: 22px;
  background: #12161f;
  box-shadow: 0 18px 40px rgba(17, 22, 30, 0.2);
}

.video-wrap video {
  display: block;
  aspect-ratio: 16 / 9;
}

.video-fallback {
  min-height: 320px;
  display: grid;
  place-items: center;
  color: rgba(255, 255, 255, 0.82);
  padding: 24px;
}

.video-fallback[hidden],
.video-wrap video[hidden] {
  display: none;
}

.lesson-content {
  margin-top: 28px;
  display: grid;
  gap: 18px;
  max-width: 960px;
}

.content-heading {
  margin: 8px 0 0;
  font-size: 1.7rem;
}

.content-paragraph {
  margin: 0;
  color: #2a3140;
  line-height: 1.75;
}

.content-list {
  margin: 0;
  padding-left: 22px;
  color: #2a3140;
  line-height: 1.75;
}

.content-note,
.plan-table-card {
  padding: 18px;
  border-radius: 20px;
  background: #fffdfa;
  border: 1px solid var(--border);
}

.content-note strong {
  display: block;
  margin-bottom: 6px;
}

.content-note p,
.content-empty {
  margin: 0;
  color: var(--muted);
  line-height: 1.7;
}

.content-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.lesson-nav {
  margin-top: 32px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.nav-btn[disabled] {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

.tabla-plan {
  width: 100%;
  border-collapse: collapse;
}

.tabla-plan th,
.tabla-plan td {
  padding: 12px 10px;
  border-bottom: 1px solid #ece4d8;
  text-align: left;
  vertical-align: top;
}

.tabla-plan thead th {
  font-size: 13px;
  color: var(--muted);
}

.btn-link {
  border: 0;
  background: transparent;
  padding: 0;
  color: var(--accent-strong);
  font-weight: 800;
  text-decoration: underline;
  cursor: pointer;
}

.detalle-box {
  margin-top: 10px;
  padding: 14px;
  border-radius: 16px;
  background: #faf6ef;
  border: 1px solid var(--border);
}

.detalle-box h4 {
  margin: 0 0 8px;
}

.detalle-content {
  color: #394254;
  line-height: 1.6;
}

.detalle-content ul {
  margin: 8px 0 0;
  padding-left: 18px;
}

.cerrar-detalle {
  margin-top: 10px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  border-radius: 10px;
  padding: 8px 12px;
  cursor: pointer;
}

@media (max-width: 1100px) {
  .app-shell {
    grid-template-columns: 300px 1fr;
  }
}

@media (max-width: 900px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .course-sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: min(92vw, 360px);
    z-index: 20;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    box-shadow: var(--shadow);
  }

  body.sidebar-open .course-sidebar {
    transform: translateX(0);
  }

  .course-main {
    padding: 18px;
  }

  .topbar {
    flex-direction: column;
    align-items: flex-start;
  }

  .topbar-left,
  .topbar-right {
    width: 100%;
  }

  .topbar-controls {
    width: 100%;
  }

  .course-select {
    width: 100%;
  }

  .password-form,
  .admin-user-form {
    grid-template-columns: 1fr;
  }

  .admin-filters,
  .metrics-grid {
    grid-template-columns: 1fr;
  }

  .admin-head {
    flex-direction: column;
  }

  .admin-user-summary,
  .detail-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 700px) {
  .lesson-shell {
    border-radius: 22px;
    padding: 20px;
  }

  .lesson-nav,
  .content-actions {
    flex-direction: column;
  }

  .nav-btn,
  .action-btn {
    width: 100%;
  }

  .topbar-right {
    flex-wrap: wrap;
  }

  .history-head,
  .history-item,
  .recent-logins-head,
  .recent-logins p {
    flex-direction: column;
    align-items: flex-start;
  }

  .user-summary-actions,
  .admin-actions,
  .danger-zone {
    width: 100%;
  }

  .user-summary-actions,
  .admin-actions,
  .danger-zone {
    justify-content: flex-start;
  }

  .tabla-plan,
  .tabla-plan tbody,
  .tabla-plan tr,
  .tabla-plan td {
    display: block;
    width: 100%;
  }

  .tabla-plan thead {
    display: none;
  }

  .tabla-plan tr {
    margin-bottom: 14px;
    border: 1px solid var(--border);
    border-radius: 16px;
    overflow: hidden;
    background: #fff;
  }

  .tabla-plan td {
    border-bottom: 1px solid #ece4d8;
  }

  .tabla-plan td:last-child {
    border-bottom: 0;
  }

  .tabla-plan td::before {
    content: attr(data-label);
    display: block;
    margin-bottom: 6px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0.06em;
    text-transform: uppercase;
  }
}
