:root {
  --bg: #f3f5f2;
  --panel: #ffffff;
  --text: #17201c;
  --muted: #66746d;
  --line: #dce5df;
  --accent: #0f7658;
  --accent-2: #e6f1ec;
  --danger: #c2410c;
  --shadow: 0 18px 45px rgba(23, 32, 28, 0.08);
}

* {
  box-sizing: border-box;
}

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

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

button {
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  padding: 10px 14px;
  cursor: pointer;
  font-weight: 700;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

button:hover {
  box-shadow: 0 8px 18px rgba(15, 118, 88, 0.16);
  transform: translateY(-1px);
}

button.secondary {
  background: #edf2f0;
  color: var(--accent);
}

button.danger {
  background: #fff1e8;
  color: var(--danger);
}

.button-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  background: #edf2f0;
  color: var(--accent);
  padding: 10px 14px;
  font-weight: 800;
  text-decoration: none;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  padding: 10px 12px;
}

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

small {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

#app {
  display: grid;
  min-height: 100vh;
  grid-template-columns: 270px 1fr;
}

.sidebar {
  background: #08110f;
  color: #fff;
  padding: 24px 18px;
  box-shadow: 18px 0 45px rgba(8, 17, 15, 0.12);
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 30px;
}

.brand-logo {
  width: 62px;
  height: 62px;
  border-radius: 8px;
  object-fit: contain;
  background: #000;
}

.brand span {
  display: block;
  margin-top: 2px;
  color: #aebbb5;
  font-size: 13px;
}

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

.nav-item {
  width: 100%;
  background: transparent;
  color: #d2ddd7;
  text-align: left;
  border: 1px solid transparent;
}

.nav-item.active,
.nav-item:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.1);
  color: #fff;
}

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

.login-card {
  max-width: 520px;
  margin: 15vh auto 0;
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  padding: 34px;
}

.login-logo {
  display: block;
  width: 150px;
  height: 150px;
  object-fit: contain;
  margin-bottom: 18px;
}

.login-card h1,
.topbar h1 {
  margin: 0;
  font-size: 28px;
}

.login-card p,
.topbar p {
  color: var(--muted);
}

.inline-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
}

.hidden {
  display: none !important;
}

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

.summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(140px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}

.metric {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 16px;
  box-shadow: 0 8px 18px rgba(23, 32, 28, 0.04);
}

.metric strong {
  display: block;
  font-size: 26px;
}

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

.content {
  min-width: 0;
  display: grid;
  gap: 14px;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 8px 20px rgba(23, 32, 28, 0.045);
  padding: 16px;
}

.proof-link {
  display: block;
  width: min(320px, 100%);
  margin-top: 12px;
}

.proof-image {
  display: block;
  width: 100%;
  max-height: 360px;
  border: 1px solid var(--line);
  border-radius: 8px;
  object-fit: contain;
  background: #f8fafb;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: start;
  margin-bottom: 14px;
}

.panel-header h2 {
  margin: 0 0 4px;
  font-size: 18px;
}

.course-builder {
  padding: 0;
  overflow: hidden;
}

.course-builder > summary {
  list-style: none;
}

.course-builder > summary::-webkit-details-marker,
.lesson-editor > summary::-webkit-details-marker {
  display: none;
}

.course-summary {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  cursor: pointer;
  padding: 18px;
}

.course-summary::before {
  content: "展开";
  order: 3;
  color: var(--accent);
  font-size: 13px;
  font-weight: 900;
}

.course-builder[open] .course-summary::before {
  content: "收起";
}

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

.course-summary-main strong {
  font-size: 20px;
}

.course-summary-main span {
  color: var(--muted);
  font-size: 13px;
}

.course-summary-meta {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.course-builder-body {
  display: grid;
  gap: 16px;
  border-top: 1px solid var(--line);
  padding: 18px;
}

.builder-section {
  display: grid;
  gap: 12px;
}

.builder-section + .builder-section {
  border-top: 1px solid var(--line);
  padding-top: 16px;
}

.builder-section-title h3 {
  margin: 0 0 4px;
  font-size: 16px;
}

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

.status {
  display: inline-flex;
  align-items: center;
  border-radius: 8px;
  background: #eef4ff;
  color: #175cd3;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 800;
}

.status.approved,
.status.active {
  background: #ecfdf3;
  color: #067647;
}

.status.rejected,
.status.revoked,
.status.blocked {
  background: #fff1e8;
  color: var(--danger);
}

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

.edit-actions {
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
  padding: 10px;
}

.lesson-group {
  border-top: 1px solid var(--line);
  padding-top: 16px;
  margin-top: 16px;
}

.lesson-group:first-of-type {
  border-top: 0;
  padding-top: 0;
  margin-top: 0;
}

.lesson-group-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: start;
  margin-bottom: 10px;
}

.lesson-group-header h3 {
  margin: 0 0 4px;
  font-size: 16px;
}

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

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

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

.file-field {
  display: grid;
  gap: 8px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: #fbfcfd;
  padding: 12px;
}

.file-field span {
  font-weight: 800;
}

.switch-field {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 8px 10px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
  padding: 12px;
}

.switch-field input {
  width: auto;
}

.switch-field span {
  font-weight: 800;
}

.switch-field small {
  grid-column: 2;
  margin-top: 0;
}

.compact-switch {
  grid-template-columns: auto 1fr;
}

.lesson-editor {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
  overflow: hidden;
}

.lesson-editor + .lesson-editor {
  margin-top: 10px;
}

.lesson-editor > summary {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) minmax(220px, 1.5fr);
  gap: 12px;
  align-items: start;
  cursor: pointer;
  padding: 12px;
}

.lesson-editor > summary strong,
.lesson-editor > summary span {
  display: block;
}

.lesson-editor > summary span {
  color: var(--muted);
  font-size: 13px;
  margin-top: 4px;
}

.lesson-editor form {
  border-top: 1px solid var(--line);
  padding: 12px;
}

.notice {
  border: 1px solid #ffe1b3;
  border-radius: 8px;
  background: #fff8ed;
  color: #9a4b00;
  padding: 12px;
  font-size: 13px;
  line-height: 1.55;
}

.notice.danger {
  border-color: #fecaca;
  background: #fff1f2;
  color: #b42318;
}

.resource-cell {
  max-width: 420px;
  overflow-wrap: anywhere;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.table {
  width: 100%;
  border-collapse: collapse;
}

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

.table th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

.empty {
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 28px;
  color: var(--muted);
  text-align: center;
}

.storefront-upload-panel {
  display: grid;
  gap: 16px;
}

.storefront-upload-panel .panel-header {
  margin-bottom: 0;
}

.banner-form {
  display: grid;
  grid-template-columns: minmax(260px, 1.45fr) minmax(260px, 1fr);
  gap: 16px;
  align-items: start;
}

.banner-form-fields,
.banner-card form {
  display: grid;
  gap: 10px;
}

.banner-preview {
  position: relative;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #e8eeeb;
}

.banner-preview img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.banner-upload-preview {
  display: grid;
  place-items: center;
  border-style: dashed;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.banner-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 14px;
}

.banner-card {
  display: grid;
  gap: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 8px 20px rgba(23, 32, 28, 0.045);
  padding: 14px;
}

.banner-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.banner-controls {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 96px;
  gap: 10px;
}

.banner-actions {
  justify-content: space-between;
}

.section-heading {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.section-heading h2,
.learning-detail h2,
.learning-detail h3 {
  margin: 0;
  font-size: 18px;
}

.section-heading p {
  margin: 4px 0 0;
}

.learning-section,
.learning-detail {
  min-width: 0;
  border-top: 1px solid var(--line);
  padding: 20px 0;
}

.learning-section:first-child,
.learning-error + .learning-section {
  border-top: 0;
  padding-top: 0;
}

.learning-detail {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 8px 20px rgba(23, 32, 28, 0.045);
  padding: 16px;
}

.learning-detail + .learning-section {
  border-top: 0;
  padding-top: 0;
}

.learning-detail .empty {
  border: 0;
  background: transparent;
  padding: 18px 0;
}

.learning-error {
  margin-bottom: 4px;
}

.learning-lessons,
.learning-course-list {
  border-top: 1px solid var(--line);
}

.learning-lesson-row {
  display: grid;
  grid-template-columns: 32px minmax(180px, 1fr) minmax(110px, auto) minmax(90px, auto);
  gap: 14px;
  align-items: center;
  border-bottom: 1px solid var(--line);
  padding: 14px 0;
}

.learning-lesson-row p {
  margin: 4px 0 0;
}

.learning-rank {
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border-radius: 8px;
  background: var(--accent-2);
  color: var(--accent);
  font-size: 13px;
  font-weight: 800;
}

.learning-row-stat {
  display: grid;
  gap: 3px;
  text-align: right;
}

.learning-row-stat strong {
  font-size: 14px;
}

.learning-row-stat span,
.table-subtext {
  color: var(--muted);
  font-size: 12px;
}

.table-subtext {
  display: block;
  margin-top: 4px;
  overflow-wrap: anywhere;
}

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

.learning-users-table,
.learning-lessons-table {
  min-width: 760px;
}

.learning-detail-heading {
  align-items: center;
}

.learning-course-row {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) minmax(150px, 2fr) 48px;
  gap: 14px;
  align-items: center;
  border-bottom: 1px solid var(--line);
  padding: 14px 0;
}

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

.learning-course-title span,
.learning-course-rate {
  color: var(--muted);
  font-size: 13px;
}

.learning-course-rate {
  text-align: right;
  font-weight: 800;
}

.progress-track {
  height: 8px;
  overflow: hidden;
  border-radius: 8px;
  background: #e7eeea;
}

.progress-track span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
}

.learning-detail-divider {
  height: 1px;
  margin: 20px 0 14px;
  background: var(--line);
}

.learning-completion {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.learning-completion.is-complete {
  color: #067647;
}

@media (max-width: 900px) {
  #app {
    grid-template-columns: minmax(0, 1fr);
  }

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 1;
  }

  nav {
    grid-template-columns: repeat(3, 1fr);
  }

  .summary,
  .grid,
  .form-grid,
  .banner-form {
    grid-template-columns: 1fr;
  }

  .learning-lesson-row,
  .learning-course-row {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .learning-rank {
    display: none;
  }

  .learning-lesson-row > div:nth-of-type(1) {
    grid-column: 1 / -1;
  }

  .learning-course-title {
    grid-column: 1 / -1;
  }
}

@media (max-width: 480px) {
  .banner-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .banner-controls {
    grid-template-columns: minmax(0, 1fr);
  }

  .main {
    padding: 18px;
  }

  .topbar,
  .section-heading,
  .learning-detail-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar > button,
  .learning-detail-heading > button {
    width: 100%;
  }
}
