/* ─── Admin panel design tokens ──────────────────────────────────────── */
:root{
  --ink:#0a0a0a; --ink-2:#2a2a30; --ink-3:#525258; --ink-4:#8a8a92;
  --line:#ececea; --line-2:#e0ddd6;
  --bg:#fff; --bg-soft:#fafaf7; --bg-tint:#f4f1ea;
  --night:#08023a; --night-2:#1a0a52;
  --purple:#7a33ff; --purple-2:#c14dff; --purple-3:#5d18d9; --purple-tint:#f3eefe;
  --grad-purple: linear-gradient(135deg, #9a3bff 0%, #5e1ad8 100%);
  --grad-card: linear-gradient(135deg, #1a0a52 0%, #08023a 60%, #14092e 100%);
  --shadow-sm:0 1px 3px rgba(10,10,10,.06), 0 1px 2px rgba(10,10,10,.04);
  --shadow-md:0 8px 30px rgba(10,10,10,.06), 0 2px 6px rgba(10,10,10,.04);
  --shadow-lg:0 24px 60px rgba(10,10,10,.10);
  --green:#14a35d; --green-tint:#e9f7ee;
  --amber:#b96a00; --amber-tint:#fff5e6;
  --red:#c83e3e; --red-tint:#fdf3f3;
  --blue:#1f5ed4; --blue-tint:#e8f0ff;
}
*{ box-sizing:border-box; }
html,body{
  margin:0; padding:0;
  height:100%;
  overflow-x: hidden;
  max-width: 100%;
}
body{
  background:var(--bg-tint);
  color:var(--ink);
  font-family:"Inter", ui-sans-serif, system-ui, -apple-system, sans-serif;
  font-size:14px; line-height:1.5;
  -webkit-font-smoothing:antialiased;
}
img, video, iframe { max-width: 100%; }
a{ color:inherit; text-decoration:none; }
button{ font-family:inherit; cursor:pointer; border:0; background:none; }

.muted{ color:var(--ink-3); font-size:12.5px; }
.ink-3{ color:var(--ink-3); }

/* ─── Boot state ─────────────────────────────────────── */
.boot-state{
  position:fixed; inset:0; display:grid; place-items:center;
  background:var(--bg-tint);
  z-index:1000;
}
.boot-card{
  background:#fff; border:1px solid var(--line); border-radius:14px;
  padding:36px 32px; min-width:320px; max-width:420px;
  text-align:center; box-shadow:var(--shadow-md);
}
.boot-card p{ margin:14px 0 0; color:var(--ink-3); }
.brand-lockup{
  font-family:"Inter Tight", sans-serif; font-weight:800;
  font-size:22px; letter-spacing:-0.025em;
  display:flex; gap:6px; align-items:baseline; justify-content:center;
}
.brand-bf{ color:var(--ink); }
.brand-grad{
  background:linear-gradient(90deg, #9a3bff 0%, #5e1ad8 100%);
  -webkit-background-clip:text; background-clip:text; color:transparent;
}
.brand-tag{
  font-size:13px; letter-spacing:.08em; text-transform:uppercase;
  background:var(--purple-tint); color:var(--purple-3);
  padding:2px 8px; border-radius:4px; font-weight:600;
  margin-left:6px;
}

/* ─── App shell ──────────────────────────────────────── */
.app{
  display:grid; grid-template-columns:240px 1fr;
  min-height:100vh;
}
.sidebar{
  background:#fff; border-right:1px solid var(--line);
  display:flex; flex-direction:column;
  padding:20px 14px;
  position:sticky; top:0; height:100vh;
}
.side-brand{
  display:flex; align-items:baseline; gap:8px;
  padding:0 8px 22px; margin-bottom:6px;
  border-bottom:1px solid var(--line);
}
.side-brand .brand{
  font-family:"Inter Tight", sans-serif; font-weight:800;
  font-size:17px; letter-spacing:-0.025em;
}
.side-tag{
  font-size:10px; letter-spacing:.1em; text-transform:uppercase;
  background:var(--purple-tint); color:var(--purple-3);
  padding:2px 7px; border-radius:4px; font-weight:700;
}
.nav{ flex:1; display:flex; flex-direction:column; gap:2px; padding-top:14px; }
.nav a{
  display:flex; align-items:center; gap:10px;
  padding:8px 10px; border-radius:8px;
  font-size:13.5px; color:var(--ink-2); font-weight:500;
  transition:background .12s ease, color .12s ease;
}
.nav a:hover{ background:var(--bg-soft); }
.nav a.active{
  background:var(--purple-tint); color:var(--purple-3); font-weight:600;
}
.nav-i{
  display:inline-flex; align-items:center; justify-content:center;
  width:22px; height:22px; color:var(--ink-3);
  font-family:"Inter Tight", sans-serif; font-weight:700; font-size:13px;
}
.nav a.active .nav-i{ color:var(--purple-3); }

.side-foot{ border-top:1px solid var(--line); padding-top:12px; }
.side-me{ display:flex; gap:10px; align-items:center; margin-bottom:8px; padding:0 6px; }
.side-me > div{ flex:1; min-width:0; overflow:hidden; }
.side-me > div > div:first-child{
  font-size:12.5px; font-weight:600; color:var(--ink-2);
  white-space:nowrap; overflow:hidden; text-overflow:ellipsis;
}
.side-avatar{
  width:30px; height:30px; border-radius:50%;
  background:var(--grad-purple); color:#fff;
  display:inline-flex; align-items:center; justify-content:center;
  font-weight:700; font-size:12px; font-family:"Inter Tight", sans-serif;
}

/* ─── Main area ──────────────────────────────────────── */
.main{ display:flex; flex-direction:column; min-width:0; }
.topbar{
  background:#fff; border-bottom:1px solid var(--line);
  padding:14px 28px;
  display:flex; align-items:center; justify-content:space-between;
  position:sticky; top:0; z-index:30;
}
.crumb{
  font-family:"Inter Tight", sans-serif; font-weight:700;
  font-size:16px; letter-spacing:-0.01em; color:var(--ink);
}
.crumb .sep{ margin:0 8px; color:var(--ink-4); font-weight:500; }
.crumb a{ color:var(--ink-3); }
.crumb a:hover{ color:var(--purple-3); }

.top-actions{ display:flex; gap:8px; align-items:center; }

.page{ padding:28px 32px 80px; max-width:1280px; width:100%; }
.loading{ color:var(--ink-3); padding:60px 0; text-align:center; }

/* ─── Reusable bits ──────────────────────────────────── */
.page-title{
  font-family:"Inter Tight", sans-serif;
  font-weight:800; font-size:28px; letter-spacing:-0.025em;
  margin:0 0 4px;
}
.page-sub{ color:var(--ink-3); margin:0 0 24px; }
.section-h{
  font-family:"Inter Tight", sans-serif; font-weight:700;
  font-size:13px; text-transform:uppercase; letter-spacing:.06em;
  color:var(--ink-2);
  margin:24px 0 12px;
}

.card{
  background:#fff; border:1px solid var(--line);
  border-radius:12px; padding:20px;
  box-shadow:var(--shadow-sm);
}
.card.dark{
  background:var(--grad-card); color:#fff; border-color:transparent;
}
.card.dark .muted{ color:rgba(255,255,255,.7); }

.stat-grid{
  display:grid; grid-template-columns:repeat(auto-fill, minmax(220px, 1fr));
  gap:14px; margin-bottom:24px;
}
.stat-card{
  background:#fff; border:1px solid var(--line);
  border-radius:12px; padding:18px 20px;
  box-shadow:var(--shadow-sm);
}
.stat-card .label{
  font-size:11.5px; color:var(--ink-3);
  text-transform:uppercase; letter-spacing:.06em;
  font-weight:600; margin-bottom:6px;
}
.stat-card .value{
  font-family:"Inter Tight", sans-serif;
  font-size:26px; font-weight:800; letter-spacing:-0.015em;
  color:var(--ink);
}
.stat-card.accent{ background:var(--grad-card); color:#fff; border-color:transparent; }
.stat-card.accent .label{ color:rgba(255,255,255,.7); }

/* Buttons */
.btn, .ghost, .primary{
  display:inline-flex; align-items:center; gap:6px;
  padding:8px 14px; border-radius:8px;
  font-size:13.5px; font-weight:600;
  border:1px solid transparent; cursor:pointer;
  transition:background .12s ease, border-color .12s ease, transform .15s ease;
}
.primary{
  background:var(--grad-purple); color:#fff; box-shadow:var(--shadow-sm);
}
.primary:hover{ transform:translateY(-1px); box-shadow:var(--shadow-md); }
.primary.small{ padding:6px 12px; font-size:12.5px; }
.ghost{
  background:#fff; border-color:var(--line); color:var(--ink-2);
}
.ghost:hover{ border-color:var(--purple); color:var(--purple-3); }
.ghost.small{ padding:6px 12px; font-size:12.5px; }
.danger{
  background:#fff; border:1px solid var(--red); color:var(--red);
  padding:8px 14px; border-radius:8px; font-size:13.5px; font-weight:600;
}
.danger:hover{ background:var(--red-tint); }

/* Tables */
table.data{
  width:100%; border-collapse:separate; border-spacing:0;
  background:#fff; border:1px solid var(--line); border-radius:12px;
  overflow:hidden;
}
table.data th, table.data td{
  text-align:left; padding:12px 16px;
  font-size:13.5px; color:var(--ink-2);
  border-bottom:1px solid var(--line);
  vertical-align:middle;
}
table.data th{
  background:var(--bg-soft); color:var(--ink-3);
  font-size:11.5px; text-transform:uppercase; letter-spacing:.06em;
  font-weight:600;
}
table.data tr:last-child td{ border-bottom:0; }
table.data tr.click{ cursor:pointer; }
table.data tr.click:hover td{ background:var(--bg-soft); }
.pill{
  display:inline-flex; align-items:center; padding:2px 10px;
  border-radius:99px; font-size:11.5px; font-weight:600;
}
.pill.green{ background:var(--green-tint); color:var(--green); }
.pill.amber{ background:var(--amber-tint); color:var(--amber); }
.pill.red{ background:var(--red-tint); color:var(--red); }
.pill.blue{ background:var(--blue-tint); color:var(--blue); }
.pill.muted{ background:var(--bg-soft); color:var(--ink-3); }
.pill.purple{ background:var(--purple-tint); color:var(--purple-3); }

/* Sub-tabs row (used by Community / Library pages) */
.subtabs{
  display:flex; gap:4px;
  background:#fff; border:1px solid var(--line);
  border-radius:12px; padding:4px;
  width:fit-content;
  margin-bottom:18px;
}
.subtab{
  padding:7px 14px; border-radius:8px;
  font-weight:600; font-size:13px; color:var(--ink-3);
  text-decoration:none;
  white-space:nowrap;
}
.subtab:hover{ background:var(--bg-soft); color:var(--ink); }
.subtab.is-active{ background:var(--ink); color:#fff; }

/* Forms */
.form-grid{
  display:grid; grid-template-columns:1fr 1fr; gap:16px 18px;
}
.form-grid.single{ grid-template-columns:1fr; }
.field{ display:flex; flex-direction:column; gap:5px; }
.field.span2{ grid-column:1 / -1; }
.field label{
  font-size:12px; color:var(--ink-3); font-weight:600;
}
.field input, .field select, .field textarea{
  padding:9px 12px; border-radius:8px;
  border:1px solid var(--line); background:#fff;
  font-size:14px; font-family:inherit; color:var(--ink);
  transition:border-color .12s ease, box-shadow .12s ease;
}
.field input:focus, .field select:focus, .field textarea:focus{
  outline:none;
  border-color:var(--purple);
  box-shadow:0 0 0 3px rgba(122,51,255,.12);
}
.field textarea{ resize:vertical; min-height:80px; font-family:inherit; }
.field-hint{ font-size:11.5px; color:var(--ink-4); margin-top:2px; }
.row-actions{ display:flex; gap:8px; align-items:center; justify-content:flex-end; }

.checkbox{ display:flex; gap:8px; align-items:center; padding:6px 0; }
.checkbox input{ accent-color:var(--purple); }

/* Toolbar */
.toolbar{
  display:flex; align-items:center; justify-content:space-between;
  gap:12px; margin-bottom:18px;
}
.search-input{
  padding:8px 12px; border-radius:8px;
  border:1px solid var(--line); background:#fff;
  font-size:13px; min-width:280px;
}

/* Toast */
.toast{
  position:fixed; bottom:20px; left:50%; transform:translateX(-50%) translateY(20px);
  background:var(--ink); color:#fff;
  padding:11px 18px; border-radius:8px; font-size:13px; font-weight:500;
  opacity:0; pointer-events:none;
  transition:transform .25s ease, opacity .25s ease;
  z-index:200;
  box-shadow:var(--shadow-md);
}
.toast.show{ opacity:1; transform:translateX(-50%) translateY(0); pointer-events:auto; }
.toast.error{ background:var(--red); }
.toast.success{ background:var(--green); }

/* Modal */
.modal-back{
  position:fixed; inset:0; background:rgba(10,10,10,.45);
  display:none; align-items:center; justify-content:center;
  z-index:100; padding:20px;
}
.modal-back.show{ display:flex; }
.modal{
  background:#fff; border-radius:14px;
  width:100%; max-width:520px;
  padding:24px; box-shadow:var(--shadow-lg);
  max-height:88vh; overflow-y:auto;
}
.modal.large{ max-width:880px; }
.modal h3{
  font-family:"Inter Tight", sans-serif; font-weight:800;
  font-size:20px; letter-spacing:-0.015em; margin:0 0 12px;
}
.modal-actions{
  display:flex; gap:10px; justify-content:flex-end; margin-top:18px;
}

/* Two-column layouts */
.split{
  display:grid; grid-template-columns:1.4fr 1fr; gap:20px;
}

/* Curriculum tree */
.curriculum-list{ display:flex; flex-direction:column; gap:10px; }
.curriculum-module{
  background:#fff; border:1px solid var(--line); border-radius:12px;
  padding:14px 16px;
}
.curriculum-module > header{
  display:flex; align-items:center; justify-content:space-between;
  margin-bottom:10px;
}
.curriculum-module > header h4{
  margin:0; font-family:"Inter Tight", sans-serif; font-weight:700;
  font-size:15px; letter-spacing:-0.005em;
}
.lesson-row{
  display:flex; align-items:center; gap:10px;
  padding:8px 10px; background:var(--bg-soft);
  border:1px solid var(--line); border-radius:8px;
  margin-top:6px;
  font-size:13.5px;
}
.lesson-row .grab{ color:var(--ink-4); cursor:grab; }
.lesson-row .title{ flex:1; }
.lesson-row .pill{ flex:0 0 auto; }
.lesson-row .actions{ display:flex; gap:6px; }
.tiny-btn{
  padding:4px 8px; border-radius:6px; font-size:11.5px; font-weight:600;
  background:#fff; border:1px solid var(--line); color:var(--ink-3);
}
.tiny-btn:hover{ border-color:var(--purple); color:var(--purple-3); }
.tiny-btn.danger{ border-color:var(--red); color:var(--red); }

/* Markdown preview pane */
.md-editor{
  display:grid; grid-template-columns:1fr 1fr; gap:14px;
  align-items:stretch;
}
.md-editor textarea{
  min-height:360px;
  font-family:"Geist Mono", ui-monospace, monospace; font-size:13px;
}
.md-preview{
  background:var(--bg-soft); border:1px solid var(--line); border-radius:8px;
  padding:16px; font-size:14px; overflow-y:auto; max-height:520px;
}
.md-preview h1, .md-preview h2, .md-preview h3{
  font-family:"Inter Tight", sans-serif; font-weight:700;
  letter-spacing:-0.015em;
}
.md-preview p{ margin:0 0 10px; }
.md-preview ul, .md-preview ol{ padding-left:22px; margin:0 0 10px; }

/* Analytics chart */
.chart-wrap{
  background:#fff; border:1px solid var(--line); border-radius:12px;
  padding:20px; margin-bottom:18px;
  height:260px;
}

/* Funnel page — slot cards layout */
.funnel-slots{
  display:flex; flex-direction:column; gap:14px;
}
.funnel-slots .card details{
  background:var(--bg-soft);
  border:1px solid var(--line);
  border-radius:10px;
  padding:14px;
  margin-top:14px;
}
.funnel-slots .card details summary{
  outline:none;
}
.funnel-slots .card details summary::-webkit-details-marker{ display:none; }
.funnel-slots .card .slot-pick{
  font-size:13.5px;
}
.funnel-slots .card code{
  background:#fff;
  border:1px solid var(--line);
  border-radius:5px;
  padding:1px 5px;
  font-family:"Geist Mono", ui-monospace, monospace;
}

@media (max-width: 900px){
  .app{ grid-template-columns:1fr; }
  .sidebar{ position:relative; height:auto; }
  .nav{ flex-direction:row; flex-wrap:wrap; gap:4px; }
  .form-grid{ grid-template-columns:1fr; }
  .split{ grid-template-columns:1fr; }
  .md-editor{ grid-template-columns:1fr; }
}
