:root {
  --bg: #f6f7fb;
  --panel: #ffffff;
  --panel-2: #f1f4f9;
  --text: #172033;
  --muted: #697386;
  --border: #dce3ee;
  --primary: #172033;
  --primary-soft: #eef2ff;
  --success: #177245;
  --warning: #a35b00;
  --danger: #b42318;
  --shadow: 0 20px 50px rgba(18, 33, 61, 0.08);
  --radius: 22px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Poppins, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
}

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

.auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at top left, rgba(23, 32, 51, 0.12), transparent 28%),
    radial-gradient(circle at bottom right, rgba(23, 32, 51, 0.08), transparent 28%),
    var(--bg);
}

.auth-card {
  width: min(440px, 100%);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 34px;
  box-shadow: var(--shadow);
}

.auth-actions {
  margin-top: 22px;
}

.auth-helper {
  margin: 0;
  font-size: 14px;
}

.brand-mark {
  width: 56px;
  height: 56px;
  border-radius: 18px;
  display: grid;
  place-items: center;
  background: var(--primary);
  color: white;
  font-weight: 900;
  letter-spacing: -0.05em;
  margin-bottom: 18px;
}

.brand-mark.small {
  width: 40px;
  height: 40px;
  border-radius: 14px;
  margin-bottom: 0;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  letter-spacing: -0.04em;
}

.muted {
  color: var(--muted);
}

.stack {
  display: grid;
  gap: 16px;
}

label {
  display: grid;
  gap: 8px;
  font-weight: 700;
  font-size: 14px;
}

input,
select,
textarea {
  border: 1px solid var(--border);
  background: white;
  border-radius: 14px;
  padding: 12px 14px;
  color: var(--text);
  outline: none;
}

textarea {
  min-height: 90px;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(23, 32, 51, 0.08);
}

.btn {
  border: 0;
  border-radius: 14px;
  padding: 12px 16px;
  cursor: pointer;
  font-weight: 800;
  transition: 0.15s ease;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.btn.primary {
  background: var(--primary);
  color: white;
}

.btn.primary[data-complete]:hover {
  background: var(--success);
}

.btn.secondary {
  background: var(--panel-2);
  color: var(--text);
}

.btn.ghost {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
}

.btn.danger {
  background: #fff0ee;
  color: var(--danger);
}

.btn.full {
  width: 100%;
}

.demo-box {
  margin-top: 20px;
  background: var(--panel-2);
  border-radius: 18px;
  padding: 16px;
  color: var(--muted);
  font-size: 14px;
}

.demo-box p {
  margin: 4px 0;
}

.layout {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 280px 1fr;
}

.sidebar {
  background: var(--panel);
  border-right: 1px solid var(--border);
  padding: 24px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 24px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.logo-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 28px;
}

.logo-row span {
  display: block;
  color: var(--muted);
  font-size: 13px;
}

nav {
  display: grid;
  gap: 8px;
}

.nav-item {
  border: 0;
  background: transparent;
  padding: 12px 14px;
  border-radius: 14px;
  text-align: left;
  font-weight: 800;
  color: var(--muted);
  cursor: pointer;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.nav-item:hover {
  color: var(--text);
  background: var(--panel-2);
}

.nav-item.active {
  color: #1d4ed8;
  background: #dbeafe;
  box-shadow: inset 0 0 0 1px #bfdbfe;
}

.nav-item-icon {
  min-width: 42px;
  height: 20px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 9px;
  letter-spacing: 0.04em;
  padding: 0 6px;
  font-weight: 900;
  color: var(--primary);
  background: var(--primary-soft);
  border: 1px solid #d9e0fb;
  flex-shrink: 0;
}

.sidebar-footer {
  display: grid;
  gap: 14px;
}

.user-mini {
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--panel-2);
}

.user-mini strong,
.user-mini span {
  display: block;
}

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

.main {
  padding: 28px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 20px;
  margin-bottom: 24px;
}

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

.progress-pill {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 10px 14px;
  font-weight: 900;
  color: var(--success);
  white-space: nowrap;
}

.badge-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.badge.success {
  background: #e7f6ee;
  color: var(--success);
}

.badge.warning {
  background: #fff4e5;
  color: var(--warning);
}

.badge.neutral {
  background: var(--panel-2);
  color: var(--text);
}

.content-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  padding: 4px 8px;
  font-size: 11px;
  font-weight: 900;
  line-height: 1;
  white-space: nowrap;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.content-badge.new {
  color: #8a2400;
  background: #fff0d6;
  border: 1px solid #ffd39b;
}

.title-with-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.grid {
  display: grid;
  gap: 18px;
}

.grid.two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

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

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: 0 12px 30px rgba(18, 33, 61, 0.04);
}

.page-switcher {
  display: grid;
  gap: 12px;
  grid-template-columns: 1fr;
  margin-top: 16px;
}

.page-chip {
  border: 1px solid var(--border);
  background: white;
  border-radius: 18px;
  padding: 16px;
  text-align: left;
  cursor: pointer;
  transition: 0.15s ease;
}

.page-chip strong,
.page-chip span {
  display: block;
}

.page-chip strong {
  margin-bottom: 6px;
}

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

.page-chip:hover,
.page-chip.active {
  border-color: var(--primary);
  background: var(--primary-soft);
}

.stat {
  display: grid;
  gap: 8px;
}

.stat strong {
  font-size: 28px;
  letter-spacing: -0.04em;
}

.timeline {
  display: grid;
  gap: 14px;
}

.milestone {
  display: grid;
  grid-template-columns: 44px 1fr;
  gap: 14px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  align-items: start;
}

.milestone > .step-number {
  margin-top: 2px;
}

.milestone > div:last-child > .milestone-header h3 {
  line-height: 44px;
  margin-bottom: 0;
}

.step-number {
  width: 44px;
  height: 44px;
  border-radius: 16px;
  background: var(--panel-2);
  display: grid;
  place-items: center;
  font-weight: 900;
}

.milestone.completed .step-number {
  background: #e7f6ee;
  color: var(--success);
}

.milestone.locked {
  background: var(--panel-2);
  border-color: transparent;
}

.milestone.is-new {
  background: #fff7e8;
  border-color: #ffd79a;
  box-shadow: 0 0 0 2px rgba(255, 191, 86, 0.18);
}

.milestone.is-new .step-number {
  background: #ffe8bf;
  color: #8a4b00;
}

.milestone.is-new.completed .step-number {
  background: #e7f6ee;
  color: var(--success);
}

.milestone-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.milestone-header .status {
  margin-top: 10px;
  flex-shrink: 0;
}

.status {
  font-size: 14px;
  font-weight: 500;
  border-radius: 999px;
  padding: 8px 14px;
  white-space: nowrap;
}

.status.complete {
  background: #e7f6ee;
  color: var(--success);
}

.status.current {
  background: #1d4ed8;
  color: white;
}

.status.locked {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  display: grid;
  place-items: center;
  z-index: 1000;
  padding: 24px;
}

.modal {
  background: var(--panel);
  border-radius: var(--radius);
  padding: 28px;
  width: min(440px, 100%);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.2);
  max-height: 85vh;
  overflow-y: auto;
}

.modal.modal-lg {
  width: min(700px, 100%);
}

.rte-toolbar {
  display: flex;
  gap: 4px;
  padding: 8px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-bottom: 0;
  border-radius: 14px 14px 0 0;
}

.rte-btn {
  border: 0;
  background: white;
  border-radius: 8px;
  padding: 6px 12px;
  cursor: pointer;
  font-size: 13px;
  transition: 0.1s ease;
}

.rte-btn:hover {
  background: var(--border);
}

.rte-editor {
  border: 1px solid var(--border);
  border-radius: 0 0 14px 14px;
  padding: 16px;
  min-height: 240px;
  background: white;
  font-size: 14px;
  line-height: 1.7;
  outline: none;
  overflow-y: auto;
}

.rte-editor:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(23, 32, 51, 0.08);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.modal-header h3 {
  margin: 0;
  line-height: 1.3;
}

.modal-close {
  border: 0;
  background: transparent;
  font-size: 24px;
  cursor: pointer;
  color: var(--muted);
  padding: 4px 8px;
  border-radius: 8px;
}

.modal-close:hover {
  background: var(--panel-2);
  color: var(--text);
}

.modal-options {
  display: grid;
  gap: 8px;
}

.modal-option {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: white;
  cursor: pointer;
  text-align: left;
  transition: 0.15s ease;
}

.modal-option:hover {
  border-color: var(--primary);
  background: var(--primary-soft);
}

.modal-option.active {
  border-color: var(--primary);
  background: var(--primary-soft);
}

.modal-option div {
  display: grid;
  gap: 2px;
}

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

.current-badge {
  margin-left: auto;
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--primary);
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
}

th,
td {
  text-align: left;
  border-bottom: 1px solid var(--border);
  padding: 14px 10px;
  vertical-align: top;
}

th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.page-row-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
}

.page-row-actions .btn {
  padding: 8px 10px;
  font-size: 12px;
  line-height: 1.1;
  white-space: nowrap;
}

.page-info-cell {
  min-width: 340px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.form-grid .full-width {
  grid-column: 1 / -1;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
}

.checkbox-row input {
  width: 18px;
  height: 18px;
  margin: 0;
}

.notice {
  background: var(--primary-soft);
  border: 1px solid #dfe5ff;
  color: #26305d;
  border-radius: 18px;
  padding: 16px;
}

.expandable-wrap {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 8px;
}

.expandable-wrap .expandable {
  flex: 1;
}

.expandable-wrap .expand-check {
  margin-top: 12px;
}

.expandable-wrap.checked .expandable {
  background: #e7f6ee;
  border-color: #b4dfc8;
}

.expandable-wrap.is-new .expandable {
  background: #fff4dc;
  border-color: #ffcf80;
}

.expandable-wrap.is-new .expandable summary:hover {
  background: #ffe8bf;
}

.expandable-wrap.checked .expandable summary:hover {
  background: #d4eede;
}

.expandable {
  background: #e8edfb;
  border: 1px solid #c7d2f0;
  border-radius: 16px;
  overflow: hidden;
}

.expandable summary {
  padding: 14px 18px;
  font-weight: 800;
  font-size: 16px;
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 8px;
  user-select: none;
  transition: background 0.15s ease;
}

.expandable summary .expand-label {
  flex: 1;
}

.expand-label-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
}

.expand-summary-meta {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.expand-summary-indicators {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.summary-indicator {
  width: 28px;
  height: 28px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--primary);
  background: rgba(23, 32, 51, 0.08);
  border: 1px solid rgba(23, 32, 51, 0.08);
  flex-shrink: 0;
}

.expand-check {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: white;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: 0.15s ease;
  flex-shrink: 0;
}

.expand-check:hover {
  border-color: var(--success);
  background: #e7f6ee;
}

.expandable-wrap.checked .expand-check {
  border-color: var(--success);
  background: var(--success);
  color: white;
}

.expandable summary::-webkit-details-marker {
  display: none;
}

.expandable summary::before {
  content: "›";
  font-size: 18px;
  font-weight: 900;
  transition: transform 0.2s ease;
  display: inline-block;
  width: 14px;
  text-align: center;
  color: var(--muted);
}

.expandable[open] summary::before {
  transform: rotate(90deg);
}

.expandable summary:hover {
  background: var(--border);
}

.expandable[open] summary {
  background: #dce6f7;
}

.expandable-wrap.is-new .expandable[open] summary {
  background: #ffe1ac;
}

.expandable-content {
  padding: 14px 18px 18px 40px;
  font-size: 15px;
  line-height: 1.8;
  color: var(--text);
}

.accordion-action-row {
  margin-top: 24px;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: flex-start;
}

.accordion-link-row {
  margin-top: 24px;
  display: flex;
  justify-content: flex-start;
}

.accordion-link-btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 13px 18px;
  border-radius: 999px;
  border: 2px solid #2563eb;
  background: linear-gradient(135deg, var(--primary) 0%, #2b3b61 100%);
  color: #fff;
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 0.01em;
  text-decoration: none;
  box-shadow: 0 12px 28px rgba(23, 32, 51, 0.2);
  transition: transform 0.15s ease, box-shadow 0.15s ease, filter 0.15s ease;
}

.accordion-link-btn:hover {
  transform: translateY(-2px);
  background: #2563eb;
  color: #fff;
  box-shadow: 0 16px 34px rgba(23, 32, 51, 0.28);
  filter: none;
}

.accordion-link-btn::after {
  content: "->";
  font-size: 13px;
}

.accordion-link-btn:focus-visible {
  outline: 3px solid rgba(23, 32, 51, 0.18);
  outline-offset: 3px;
}

.accordion-video-btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 13px 18px;
  border-radius: 999px;
  border: 2px solid #f3b5b5;
  background: #fff7f7;
  color: #8f1d1d;
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 0.01em;
  box-shadow: 0 12px 28px rgba(180, 38, 38, 0.12);
}

.accordion-video-btn:hover {
  transform: translateY(-2px);
  background: #7f1d1d;
  color: #fff;
  border-color: #7f1d1d;
  box-shadow: 0 16px 34px rgba(127, 29, 29, 0.24);
}

.video-btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.video-modal {
  width: min(900px, 100%);
}

.video-frame-wrap {
  position: relative;
  width: 100%;
  padding-top: 56.25%;
  border-radius: 18px;
  overflow: hidden;
  background: #0f172a;
}

.video-frame-wrap iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

.video-modal-help {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 16px;
}

.video-modal-help .muted {
  margin: 0;
}

.error {
  color: var(--danger);
  font-weight: 800;
  margin-top: 10px;
}

.template-card {
  margin-bottom: 12px;
  transition: box-shadow 0.15s ease, opacity 0.15s ease;
  cursor: default;
}

.template-card.dragging {
  opacity: 0.4;
}

.template-card.drag-over {
  box-shadow: 0 0 0 3px var(--primary), var(--shadow);
}

.template-milestone-header {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  margin-bottom: 16px;
}

.template-drag-handle {
  font-size: 20px;
  color: var(--muted);
  cursor: grab;
  padding: 4px;
  user-select: none;
  line-height: 1;
}

.template-drag-handle:active {
  cursor: grabbing;
}

.template-milestone-info {
  flex: 1;
}

.template-milestone-info h3 {
  margin: 0 0 4px;
  line-height: 1.3;
}

.template-milestone-info .muted {
  margin: 0;
  font-size: 13px;
}

.template-assigned {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  margin-top: 4px;
  display: inline-block;
}

.template-milestone-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.template-sections {
  display: grid;
  gap: 6px;
  margin-bottom: 12px;
}

.template-section {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.template-section > span {
  flex: 1;
}

.section-drag-handle {
  color: var(--muted);
  cursor: grab;
  font-size: 14px;
  user-select: none;
  line-height: 1;
}

.section-drag-handle:active {
  cursor: grabbing;
}

.template-section.dragging {
  opacity: 0.4;
}

.template-section.section-drag-over {
  border-color: var(--primary);
  background: var(--primary-soft);
}

.template-section span {
  font-size: 14px;
  font-weight: 600;
}

.template-section-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.template-section-actions .btn {
  padding: 5px 10px;
  font-size: 12px;
}

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

  .sidebar {
    height: auto;
    position: static;
  }

  .topbar {
    flex-direction: column;
  }

  .grid.two,
  .grid.three,
  .form-grid {
    grid-template-columns: 1fr;
  }
}
