@import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@400;500;600;700;800&display=swap');
:root {
  --primary: #5B14B7; --primary-600: #4a0f97; --primary-50: #f3ecfd; --secondary: #DD3CBD; --accent: #FFC629;
  --bg: #f6f4fb; --surface: #ffffff; --text: #1f1638; --muted: #6b6485; --border: #e4def0;
  --ok: #1a9b5c; --warn: #d48806; --bad: #d23b3b; --radius: 14px;
  --shadow: 0 2px 10px rgba(40, 10, 90, .07); --shadow-lg: 0 12px 40px rgba(40, 10, 90, .18);
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body { font-family: Montserrat, system-ui, -apple-system, 'Segoe UI', sans-serif; background: var(--bg); color: var(--text); font-size: 15px; line-height: 1.45; }
a { color: var(--primary); }
h1, h2, h3 { margin: 0 0 .5em; line-height: 1.2; }
button, input, select, textarea { font: inherit; color: inherit; }

/* Barra superior */
.topbar { height: 64px; background: var(--surface); border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 16px; padding: 0 24px; position: sticky; top: 0; z-index: 50; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 19px; color: var(--primary); text-decoration: none; }
.brand-logo { width: 36px; height: 36px; border-radius: 10px; background: linear-gradient(135deg, var(--primary), var(--secondary)); display: grid; place-items: center; color: #fff; font-size: 18px; }
.topbar .spacer { flex: 1; }
.topbar nav { display: flex; gap: 4px; }
.topbar nav a { padding: 8px 14px; border-radius: 10px; text-decoration: none; color: var(--muted); font-weight: 600; }
.topbar nav a.active, .topbar nav a:hover { background: var(--primary-50); color: var(--primary); }
.user-chip { display: flex; align-items: center; gap: 8px; font-weight: 600; color: var(--muted); cursor: pointer; position: relative; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--secondary); color: #fff; display: grid; place-items: center; font-weight: 700; }
.menu { position: absolute; right: 0; top: 46px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-lg); padding: 6px; min-width: 200px; display: none; }
.menu.open { display: block; }
.menu button { display: block; width: 100%; text-align: left; border: 0; background: none; padding: 9px 12px; border-radius: 8px; cursor: pointer; }
.menu button:hover { background: var(--primary-50); }

.container { max-width: 1240px; margin: 0 auto; padding: 28px 24px 60px; }
.page-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 22px; }
.page-head h1 { font-size: 26px; margin: 0; }
.page-head .spacer { flex: 1; }
.muted { color: var(--muted); }

/* Botones */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 10px 18px; border-radius: 11px; border: 1px solid transparent; background: var(--primary); color: #fff; font-weight: 700; cursor: pointer; text-decoration: none; transition: .15s; white-space: nowrap; }
.btn:hover { background: var(--primary-600); }
.btn.secondary { background: var(--surface); color: var(--primary); border-color: var(--border); }
.btn.secondary:hover { background: var(--primary-50); }
.btn.pink { background: var(--secondary); }
.btn.accent { background: var(--accent); color: #2b0a5c; }
.btn.danger { background: #fff; color: var(--bad); border-color: #f2caca; }
.btn.danger:hover { background: #fdeeee; }
.btn.ghost { background: transparent; color: var(--muted); }
.btn.ghost:hover { background: var(--primary-50); color: var(--primary); }
.btn.sm { padding: 6px 11px; font-size: 13px; border-radius: 9px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* Formularios */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field label { font-weight: 600; font-size: 13px; color: var(--muted); }
.input, select.input, textarea.input { width: 100%; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--border); background: #fff; outline: none; }
.input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(91, 20, 183, .12); }
.row { display: flex; gap: 12px; } .row > * { flex: 1; }

/* Tarjetas de curso */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: 20px; }
.card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); border: 1px solid var(--border); overflow: hidden; display: flex; flex-direction: column; }
.course-cover { aspect-ratio: 16/9; background: linear-gradient(135deg, var(--primary), var(--secondary)); position: relative; display: grid; place-items: center; color: #fff; font-weight: 800; font-size: 22px; text-align: center; padding: 14px; overflow: hidden; }
.course-cover img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.course-cover .badge { position: absolute; top: 10px; left: 10px; z-index: 2; }
.card-body { padding: 16px; flex: 1; display: flex; flex-direction: column; gap: 8px; }
.card-body h3 { font-size: 17px; margin: 0; }
.card-body p { margin: 0; color: var(--muted); font-size: 14px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card-foot { padding: 0 16px 16px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.progress { height: 8px; background: var(--primary-50); border-radius: 99px; overflow: hidden; }
.progress > div { height: 100%; background: linear-gradient(90deg, var(--primary), var(--secondary)); border-radius: 99px; }
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px; border-radius: 99px; font-size: 12px; font-weight: 700; background: var(--primary-50); color: var(--primary); }
.badge.ok { background: #e3f6ec; color: var(--ok); } .badge.warn { background: #fff4dc; color: var(--warn); }
.badge.bad { background: #fde8e8; color: var(--bad); } .badge.gray { background: #eeecf3; color: var(--muted); }
.badge.dark { background: rgba(0,0,0,.55); color: #fff; }

/* Tablas */
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.panel-head { padding: 16px 18px; border-bottom: 1px solid var(--border); display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 11px 14px; text-align: left; border-bottom: 1px solid var(--border); font-size: 14px; vertical-align: middle; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); background: #faf8fe; }
tr:last-child td { border-bottom: 0; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 16px; margin-bottom: 22px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.stat b { display: block; font-size: 30px; color: var(--primary); }
.stat span { color: var(--muted); font-size: 13px; font-weight: 600; }

/* Pestañas */
.tabs { display: flex; gap: 6px; margin-bottom: 22px; border-bottom: 1px solid var(--border); }
.tabs button { border: 0; background: none; padding: 12px 16px; font-weight: 700; color: var(--muted); cursor: pointer; border-bottom: 3px solid transparent; margin-bottom: -1px; }
.tabs button.active { color: var(--primary); border-color: var(--primary); }

/* Modal */
.modal-bg { position: fixed; inset: 0; background: rgba(25, 10, 50, .45); display: grid; place-items: center; z-index: 200; padding: 16px; }
.modal { background: var(--surface); border-radius: 18px; box-shadow: var(--shadow-lg); width: 100%; max-width: 520px; max-height: 90vh; overflow: auto; }
.modal-head { padding: 18px 22px; border-bottom: 1px solid var(--border); display: flex; align-items: center; }
.modal-head h2 { margin: 0; font-size: 19px; flex: 1; }
.modal-body { padding: 20px 22px; }
.modal-foot { padding: 14px 22px; border-top: 1px solid var(--border); display: flex; gap: 10px; justify-content: flex-end; }
.x { border: 0; background: none; font-size: 22px; cursor: pointer; color: var(--muted); }

/* Notificaciones */
#toasts { position: fixed; bottom: 20px; right: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 500; }
.toast { background: #24133f; color: #fff; padding: 12px 16px; border-radius: 12px; box-shadow: var(--shadow-lg); font-weight: 600; animation: tin .25s; max-width: 380px; }
.toast.err { background: var(--bad); }
@keyframes tin { from { transform: translateY(10px); opacity: 0; } }

.empty { text-align: center; padding: 50px 20px; color: var(--muted); }
.empty .big { font-size: 48px; }
.dropzone { border: 2px dashed var(--border); border-radius: 14px; padding: 30px; text-align: center; color: var(--muted); cursor: pointer; transition: .15s; }
.dropzone.over, .dropzone:hover { border-color: var(--primary); background: var(--primary-50); color: var(--primary); }
.uploadbar { height: 10px; background: var(--primary-50); border-radius: 99px; overflow: hidden; margin-top: 14px; display: none; }
.uploadbar div { height: 100%; width: 0; background: var(--primary); transition: width .2s; }
.switch { position: relative; width: 42px; height: 24px; display: inline-block; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; background: #d6d0e3; border-radius: 99px; cursor: pointer; transition: .2s; }
.switch span::before { content: ''; position: absolute; width: 18px; height: 18px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .2s; }
.switch input:checked + span { background: var(--ok); }
.switch input:checked + span::before { transform: translateX(18px); }
.filters { display: flex; gap: 10px; flex-wrap: wrap; }
.filters .input { width: auto; min-width: 180px; }

@media (max-width: 720px) {
  .topbar { padding: 0 14px; gap: 8px; }
  .topbar nav a { padding: 8px 8px; font-size: 13px; }
  .user-chip .uname, .brand span { display: none; }
  .container { padding: 18px 16px 50px; }
  .row { flex-direction: column; gap: 0; }
}
