/* ==========================================================================
   Admin shell + view-specific layout
   ========================================================================== */

.shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  height: 100vh;
  overflow: hidden;
}

/* --- Sidebar -------------------------------------------------------------- */
.side {
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.side__brand {
  display: flex;
  align-items: center;
  gap: 9px;
  height: var(--topbar-h);
  padding: 0 16px;
  border-bottom: 1px solid var(--border);
  flex: none;
}
.side__mark {
  width: 26px; height: 26px;
  border-radius: var(--r-xs);
  background: var(--fp-red);
  display: grid;
  place-items: center;
  flex: none;
  box-shadow: var(--sh-red);
}
.side__mark span {
  display: block;
  width: 11px; height: 13px;
  background: #fff;
  clip-path: polygon(0 0, 46% 0, 100% 50%, 46% 100%, 0 100%, 54% 50%);
}
.side__word {
  display: block;
  font-size: 12.5px;
  font-weight: var(--fw-extrabold);
  letter-spacing: 0.03em;
  text-transform: uppercase;
  line-height: 1.15;
}
.side__word em { font-style: normal; font-weight: var(--fw-regular); color: var(--text-3); }
.side__sub {
  font-size: 9px;
  letter-spacing: 0.18em;
  color: var(--fp-red);
  font-weight: var(--fw-bold);
}

.side__nav {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 12px 10px 16px;
  min-height: 0;
}
.side__group { margin-bottom: 16px; }
.side__group-label {
  font-size: 9.5px;
  font-weight: var(--fw-bold);
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--text-3);
  padding: 0 8px 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 7px 9px;
  border-radius: var(--r-sm);
  font-size: 12.5px;
  font-weight: var(--fw-medium);
  color: var(--text-2);
  transition: background var(--t-fast), color var(--t-fast);
  position: relative;
}
.nav-item svg { width: 15px; height: 15px; flex: none; opacity: 0.85; }
.nav-item:hover { background: var(--surface-3); color: var(--text); }
.nav-item.is-active {
  background: var(--red-bg);
  color: #fff;
  font-weight: var(--fw-semibold);
}
.nav-item.is-active svg { color: var(--fp-red); opacity: 1; }
.nav-item.is-active::before {
  content: "";
  position: absolute;
  left: -10px; top: 6px; bottom: 6px;
  width: 3px;
  background: var(--fp-red);
  border-radius: 0 2px 2px 0;
}
.nav-item__badge {
  margin-left: auto;
  background: var(--fp-red);
  color: #fff;
  font-size: 10px;
  font-weight: var(--fw-bold);
  padding: 1px 6px;
  border-radius: var(--r-pill);
}
.nav-item__soon {
  margin-left: auto;
  font-size: 8.5px;
  font-weight: var(--fw-bold);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-3);
  border: 1px solid var(--border-hi);
  padding: 1px 5px;
  border-radius: var(--r-xs);
}

.side__foot {
  flex: none;
  border-top: 1px solid var(--border);
  padding: 10px;
}
.side__user {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 7px 8px;
  border-radius: var(--r-sm);
  transition: background var(--t-fast);
  text-align: left;
}
.side__user:hover { background: var(--surface-3); }
.side__user svg { width: 14px; height: 14px; flex: none; color: var(--text-3); }
.side__sub { display: block; }

/* --- Main ----------------------------------------------------------------- */
.main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

.topbar {
  height: var(--topbar-h);
  flex: none;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 20px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.topbar__title { display: flex; flex-direction: column; min-width: 0; }
.crumbs {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 10.5px;
  font-weight: var(--fw-semibold);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-3);
}
.crumbs a:hover { color: var(--text-2); }
.crumbs span { opacity: 0.5; }

.topbar__search { width: min(300px, 30vw); }
.topbar__actions { display: flex; align-items: center; gap: 8px; margin-left: auto; }

.icon-btn {
  position: relative;
  width: 32px; height: 32px;
  display: grid;
  place-items: center;
  border-radius: var(--r-sm);
  color: var(--text-2);
  transition: background var(--t-fast), color var(--t-fast);
}
.icon-btn:hover { background: var(--surface-3); color: var(--text); }
.icon-btn svg { width: 16px; height: 16px; }
.icon-btn__dot {
  position: absolute;
  top: 6px; right: 6px;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--fp-red);
  border: 1.5px solid var(--surface);
}

.mobile-toggle { display: none; }

/* --- Page ----------------------------------------------------------------- */
.page {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 22px 24px 56px;
  min-height: 0;
}
.page__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}
.page__lede { max-width: 620px; margin-top: 6px; }
.page__actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.section { margin-bottom: 26px; }
.section__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

/* --- Grids ---------------------------------------------------------------- */
.grid { display: grid; gap: 14px; }
.grid--4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid--2-1 { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.grid--1-2 { grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); }

.toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.toolbar__spacer { flex: 1 1 auto; }

/* --- Program builder ------------------------------------------------------ */
.builder { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 16px; align-items: start; }

.module {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  margin-bottom: 12px;
  overflow: hidden;
}
.module__head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 12px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
}
.module__title { font-weight: var(--fw-bold); font-size: 13.5px; }
.module__meta { font-size: 11px; color: var(--text-3); }
.module__body { padding: 6px; }
.module.is-collapsed .module__body { display: none; }
.module__caret { transition: transform var(--t-fast); }
.module.is-collapsed .module__caret { transform: rotate(-90deg); }

.lesson {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--r-sm);
  transition: background var(--t-fast);
  cursor: pointer;
}
.lesson:hover { background: var(--surface-2); }
.lesson.is-selected { background: var(--red-bg); }
.lesson__idx {
  width: 20px;
  font-size: 11px;
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
  flex: none;
  text-align: right;
}
.lesson__title { font-size: 13px; font-weight: var(--fw-medium); }
.lesson__acts { display: flex; gap: 3px; }
.act-chip {
  display: inline-grid;
  place-items: center;
  width: 20px; height: 20px;
  border-radius: var(--r-xs);
  background: var(--surface-3);
  color: var(--text-3);
}
.act-chip svg { width: 11px; height: 11px; }
.act-chip--video { background: rgba(200,0,0,.18); color: #FF7A7A; }
.act-chip--text { background: rgba(74,158,232,.15); color: var(--info); }
.act-chip--pdf { background: rgba(232,163,61,.15); color: var(--warn); }
.act-chip--quiz { background: rgba(47,191,113,.15); color: var(--ok); }

.lesson__row-actions { display: flex; gap: 2px; margin-left: auto; opacity: 0; transition: opacity var(--t-fast); }
.lesson:hover .lesson__row-actions,
.lesson.is-selected .lesson__row-actions { opacity: 1; }

/* --- Activity editor ------------------------------------------------------ */
.activity {
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  margin-bottom: 10px;
  background: var(--surface-2);
  overflow: hidden;
}
.activity__head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 11px;
  border-bottom: 1px solid var(--border);
}
.activity__body { padding: 12px; }
.activity__type {
  font-size: 10.5px;
  font-weight: var(--fw-bold);
  text-transform: uppercase;
  letter-spacing: 0.09em;
}

.act-picker { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.act-picker button {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 11px;
  border: 1px dashed var(--border-hi);
  border-radius: var(--r-sm);
  color: var(--text-2);
  font-size: 12.5px;
  font-weight: var(--fw-medium);
  transition: border-color var(--t-fast), background var(--t-fast), color var(--t-fast);
}
.act-picker button:hover {
  border-color: var(--fp-red);
  background: var(--red-bg);
  color: var(--text);
}
.act-picker svg { width: 15px; height: 15px; }

/* --- Calendar ------------------------------------------------------------- */
.cal { border: 1px solid var(--border); border-radius: var(--r-md); overflow: hidden; }
.cal__grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.cal__dow {
  padding: 8px;
  text-align: center;
  font-size: 10px;
  font-weight: var(--fw-bold);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-3);
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
}
.cal__cell {
  min-height: 92px;
  padding: 6px;
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.cal__cell:nth-child(7n) { border-right: 0; }
.cal__cell--out { background: var(--bg); }
.cal__daynum { font-size: 11px; color: var(--text-3); font-variant-numeric: tabular-nums; }
.cal__cell--today .cal__daynum {
  display: inline-grid;
  place-items: center;
  width: 19px; height: 19px;
  border-radius: 50%;
  background: var(--fp-red);
  color: #fff;
  font-weight: var(--fw-bold);
}
.cal__event {
  margin-top: 4px;
  padding: 3px 6px;
  border-radius: var(--r-xs);
  background: var(--red-bg-hi);
  border-left: 2px solid var(--fp-red);
  font-size: 10.5px;
  font-weight: var(--fw-medium);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: pointer;
}
.cal__event:hover { background: rgba(200,0,0,.32); }

/* --- Charts (pure CSS) ---------------------------------------------------- */
.chart-bars {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  height: 150px;
  padding-top: 8px;
}
.chart-bars__col { flex: 1 1 0; display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; }
.chart-bars__track { flex: 1 1 auto; width: 100%; display: flex; align-items: flex-end; }
.chart-bars__bar {
  width: 100%;
  background: linear-gradient(180deg, var(--fp-red), var(--fp-dark-maroon));
  border-radius: 2px 2px 0 0;
  min-height: 3px;
  transition: opacity var(--t-fast);
}
.chart-bars__col:hover .chart-bars__bar { opacity: 0.78; }
.chart-bars__lbl { font-size: 10px; color: var(--text-3); }

.funnel__row { display: flex; align-items: center; gap: 12px; margin-bottom: 9px; }
.funnel__lbl { width: 132px; font-size: 12px; color: var(--text-2); flex: none; }
.funnel__track { flex: 1 1 auto; height: 22px; background: var(--surface-3); border-radius: var(--r-xs); overflow: hidden; }
.funnel__fill {
  height: 100%;
  background: linear-gradient(90deg, var(--fp-red), var(--fp-brick-red));
  display: flex;
  align-items: center;
  padding-left: 8px;
  font-size: 11px;
  font-weight: var(--fw-bold);
}

/* --- Branding preview ----------------------------------------------------- */
.swatch-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); gap: 10px; }
.swatch { border: 1px solid var(--border); border-radius: var(--r-sm); overflow: hidden; }
.swatch__chip { height: 52px; }
.swatch__meta { padding: 7px 9px; background: var(--surface-2); }
.swatch__name { font-size: 11.5px; font-weight: var(--fw-semibold); }
.swatch__hex { font-size: 10.5px; color: var(--text-3); font-family: ui-monospace, Consolas, monospace; }

.email-preview {
  background: var(--n-100);
  color: var(--n-900);
  border-radius: var(--r-sm);
  overflow: hidden;
  border: 1px solid var(--border);
}
.email-preview__bar { background: var(--fp-red); padding: 15px 18px; display: flex; align-items: center; gap: 8px; }
.email-preview__body { padding: 18px; font-size: 13px; line-height: 1.6; }
.email-preview__btn {
  display: inline-block;
  background: var(--fp-red);
  color: #fff;
  padding: 9px 18px;
  border-radius: var(--r-sm);
  font-weight: var(--fw-bold);
  font-size: 12.5px;
  margin: 12px 0;
}
.email-preview__foot {
  padding: 13px 18px;
  background: var(--n-200);
  font-size: 11px;
  color: var(--n-600);
}

/* --- Preview (draft program) --------------------------------------------- */
.preview-frame {
  border: 1px solid var(--border-hi);
  border-radius: var(--r-md);
  overflow: hidden;
  background: #000;
}
.preview-frame__bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: var(--surface-3);
  border-bottom: 1px solid var(--border);
}
.preview-frame__dots { display: flex; gap: 5px; }
.preview-frame__dots i { width: 9px; height: 9px; border-radius: 50%; background: var(--surface-4); display: block; }
.preview-frame__url {
  flex: 1 1 auto;
  background: var(--surface);
  border-radius: var(--r-pill);
  padding: 3px 12px;
  font-size: 11px;
  color: var(--text-3);
  text-align: center;
}

/* --- Login ---------------------------------------------------------------- */
.login {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1fr 1fr;
}
.login__art {
  position: relative;
  background: linear-gradient(140deg, var(--fp-dark-maroon), var(--fp-near-black) 60%, #000);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 42px;
}
.login__art::after {
  content: "";
  position: absolute;
  right: -110px; top: 50%;
  width: 420px; height: 420px;
  transform: translateY(-50%);
  background: var(--fp-red);
  clip-path: polygon(0 0, 46% 0, 100% 50%, 46% 100%, 0 100%, 54% 50%);
  opacity: 0.16;
}
.login__art-inner { position: relative; z-index: 1; }
.login__form-side {
  display: grid;
  place-items: center;
  padding: 32px;
  background: var(--surface);
}
.login__form { width: 100%; max-width: 352px; }

.social-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.social-btn {
  height: 36px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--surface-2);
  display: grid;
  place-items: center;
  transition: border-color var(--t-fast), background var(--t-fast);
}
.social-btn:hover { border-color: var(--border-hi); background: var(--surface-3); }
.social-btn svg { width: 17px; height: 17px; }

.or-line {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 18px 0;
  color: var(--text-3);
  font-size: 10.5px;
  font-weight: var(--fw-bold);
  letter-spacing: 0.12em;
}
.or-line::before, .or-line::after {
  content: "";
  flex: 1 1 auto;
  height: 1px;
  background: var(--border);
}

/* --- Website stub --------------------------------------------------------- */
.stub {
  display: grid;
  place-items: center;
  min-height: 420px;
  text-align: center;
  padding: 40px 24px;
  border: 1px dashed var(--border-hi);
  border-radius: var(--r-lg);
  background:
    radial-gradient(ellipse at 50% 0%, rgba(200,0,0,.09), transparent 62%),
    var(--surface);
}
.stub__mark {
  width: 58px; height: 58px;
  margin: 0 auto 18px;
  border-radius: var(--r-md);
  background: var(--red-bg-hi);
  display: grid;
  place-items: center;
  color: var(--fp-red);
}
.stub__mark svg { width: 26px; height: 26px; }

/* --- Responsive ----------------------------------------------------------- */
@media (max-width: 1180px) {
  .grid--4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .builder { grid-template-columns: minmax(0, 1fr); }
  .grid--2-1, .grid--1-2 { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .side {
    position: fixed;
    inset: 0 auto 0 0;
    width: var(--sidebar-w);
    z-index: 180;
    transform: translateX(-100%);
    transition: transform var(--t);
    box-shadow: var(--sh-3);
  }
  body.nav-open .side { transform: none; }
  body.nav-open::after {
    content: "";
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.6);
    z-index: 170;
  }
  .mobile-toggle { display: grid; }
  .topbar__search { display: none; }
  .grid--3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .login { grid-template-columns: 1fr; }
  .login__art { display: none; }
}

@media (max-width: 640px) {
  .page { padding: 16px 14px 48px; }
  .topbar { padding: 0 14px; }
  .grid--4, .grid--3, .grid--2 { grid-template-columns: minmax(0, 1fr); }
  .t-display { font-size: 23px; }
  .kv { grid-template-columns: 1fr; gap: 3px 0; }
  .kv dd { margin-bottom: 8px; }
  .act-picker { grid-template-columns: 1fr; }
}
