:root {
  --bg: #f4f6f5;
  --surface: #ffffff;
  --surface-soft: #f8faf9;
  --text: #17201e;
  --muted: #69736f;
  --line: #dce2df;
  --brand: #176b5b;
  --brand-dark: #105345;
  --brand-soft: #e2f1ec;
  --blue: #3267b1;
  --blue-soft: #e8eff9;
  --amber: #9b6519;
  --amber-soft: #f8eedc;
  --red: #aa4545;
  --shadow: 0 8px 24px rgba(28, 42, 38, 0.08);
  --sidebar: 228px;
}

* { box-sizing: border-box; }

html { background: var(--bg); }

body {
  margin: 0;
  color: var(--text);
  background: var(--bg);
  font-family: Inter, "PingFang SC", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
  font-size: 14px;
  letter-spacing: 0;
}

button,
input { font: inherit; }

button,
a { -webkit-tap-highlight-color: transparent; }

button { color: inherit; }

[hidden] { display: none !important; }

.app {
  min-height: 100vh;
  display: grid;
  grid-template-columns: var(--sidebar) minmax(0, 1fr);
}

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar);
  padding: 24px 18px;
  display: flex;
  flex-direction: column;
  background: #ffffff;
  border-right: 1px solid var(--line);
  z-index: 20;
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 0;
}

.brand > div:last-child {
  min-width: 0;
  display: grid;
  gap: 1px;
}

.brand strong {
  font-size: 15px;
  line-height: 1.2;
}

.brand span {
  color: var(--muted);
  font-size: 12px;
}

.brand-badge {
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
  display: grid;
  place-items: center;
  border-radius: 7px;
  color: #ffffff;
  background: var(--brand);
  font-size: 18px;
  font-weight: 800;
}

.desktop-nav {
  display: grid;
  gap: 6px;
  margin-top: 34px;
}

.nav-button {
  height: 44px;
  padding: 0 13px;
  display: flex;
  align-items: center;
  gap: 11px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: #53605c;
  cursor: pointer;
  text-align: left;
}

.nav-button svg { width: 19px; height: 19px; }

.nav-button:hover { background: var(--surface-soft); }

.nav-button.active {
  color: var(--brand-dark);
  background: var(--brand-soft);
  font-weight: 650;
}

.sidebar-user {
  margin-top: auto;
  padding-top: 18px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-top: 1px solid var(--line);
}

.sidebar-user > div:last-child {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.sidebar-user strong,
.sidebar-user span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

.avatar {
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: var(--brand-dark);
  background: var(--brand-soft);
  font-weight: 750;
}

.avatar.large {
  width: 56px;
  height: 56px;
  flex-basis: 56px;
  font-size: 20px;
}

.workspace {
  grid-column: 2;
  min-width: 0;
}

.mobile-header,
.mobile-nav { display: none; }

.content {
  width: min(1180px, 100%);
  margin: 0 auto;
  padding: 38px 42px 64px;
}

.view { min-width: 0; }

.page-heading,
.section-heading,
.profile-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.page-heading { margin-bottom: 24px; }

.page-heading h1,
.profile-header h1 {
  margin: 3px 0 0;
  font-size: 27px;
  line-height: 1.2;
}

.eyebrow {
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.text-button {
  padding: 6px 0;
  border: 0;
  color: var(--brand);
  background: transparent;
  cursor: pointer;
  font-weight: 650;
}

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

.progress-band {
  padding: 24px 26px;
  display: grid;
  grid-template-columns: 150px minmax(180px, 1fr) auto;
  align-items: center;
  gap: 24px;
  background: #193c35;
  color: #ffffff;
}

.progress-copy { display: grid; gap: 4px; }
.progress-copy span { color: #c8d9d4; font-size: 12px; }
.progress-copy strong { font-size: 31px; line-height: 1; }

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

.progress-track span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: #8bd0b7;
  transition: width 220ms ease;
}

.progress-stats {
  margin: 0;
  display: grid;
  grid-template-columns: repeat(3, minmax(66px, 1fr));
  gap: 18px;
}

.progress-stats div { display: grid; gap: 4px; }
.progress-stats dt { color: #c8d9d4; font-size: 12px; }
.progress-stats dd { margin: 0; font-size: 20px; font-weight: 750; }

.content-section { margin-top: 34px; }
.section-heading { margin-bottom: 15px; }
.section-heading h2 { margin: 0; font-size: 17px; }

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

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

.course-card {
  min-width: 0;
  min-height: 168px;
  padding: 17px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  cursor: pointer;
  transition: border-color 150ms ease, box-shadow 150ms ease, transform 150ms ease;
}

.course-card:hover {
  border-color: #aebbb6;
  box-shadow: var(--shadow);
  transform: translateY(-1px);
}

.course-card:focus-visible {
  outline: 3px solid rgba(50, 103, 177, 0.25);
  outline-offset: 2px;
}

.course-topline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.course-domain {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--brand-dark);
  font-size: 11px;
  font-weight: 700;
}

.course-state {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--muted);
  font-size: 11px;
}

.course-state svg { width: 14px; height: 14px; }
.course-state.completed { color: var(--brand); }
.course-state.learning { color: var(--blue); }

.course-card h3 {
  margin: 0;
  display: -webkit-box;
  overflow: hidden;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  font-size: 15px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.course-card-footer {
  margin-top: auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 11px;
}

.course-resources { display: flex; gap: 8px; }
.course-resources span { display: inline-flex; align-items: center; gap: 3px; }
.course-resources svg { width: 13px; height: 13px; }

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

.path-button {
  min-height: 98px;
  padding: 15px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: space-between;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  cursor: pointer;
  text-align: left;
}

.path-button:hover { border-color: #aebbb6; }
.path-button svg { width: 20px; height: 20px; color: var(--brand); }
.path-button:nth-child(2) svg { color: var(--blue); }
.path-button:nth-child(3) svg { color: var(--amber); }
.path-button:nth-child(4) svg { color: var(--red); }
.path-button:nth-child(5) svg { color: #6e559f; }
.path-button strong { font-size: 13px; line-height: 1.35; }
.path-button span { color: var(--muted); font-size: 11px; }

.search-box {
  height: 46px;
  padding: 0 13px;
  display: flex;
  align-items: center;
  gap: 9px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
}

.search-box:focus-within {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(50, 103, 177, 0.12);
}

.search-box > svg { width: 18px; height: 18px; color: var(--muted); }
.search-box input { min-width: 0; flex: 1; border: 0; outline: 0; background: transparent; color: var(--text); }
.search-box input::placeholder { color: #9aa39f; }

.filter-row {
  margin: 14px 0 18px;
  padding-bottom: 2px;
  display: flex;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: none;
}

.filter-row::-webkit-scrollbar { display: none; }

.filter-chip {
  min-height: 34px;
  padding: 0 13px;
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 17px;
  background: var(--surface);
  cursor: pointer;
  color: #53605c;
  white-space: nowrap;
}

.filter-chip.active {
  border-color: var(--brand);
  color: #ffffff;
  background: var(--brand);
}

.profile-header {
  justify-content: flex-start;
  margin-bottom: 22px;
}

.profile-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border: 1px solid var(--line);
  background: var(--surface);
}

.profile-stats button {
  min-height: 88px;
  display: grid;
  place-content: center;
  gap: 4px;
  border: 0;
  border-right: 1px solid var(--line);
  background: transparent;
  cursor: pointer;
}

.profile-stats button:last-child { border-right: 0; }
.profile-stats strong { font-size: 23px; }
.profile-stats span { color: var(--muted); font-size: 12px; }

.segmented {
  width: fit-content;
  margin: 24px 0 16px;
  padding: 3px;
  display: flex;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #e9eeec;
}

.segmented button {
  min-width: 76px;
  min-height: 34px;
  padding: 0 13px;
  border: 0;
  border-radius: 5px;
  background: transparent;
  cursor: pointer;
  color: var(--muted);
}

.segmented button.active {
  color: var(--text);
  background: #ffffff;
  box-shadow: 0 1px 3px rgba(28, 42, 38, 0.1);
  font-weight: 650;
}

.admin-metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  border: 1px solid var(--line);
  background: var(--surface);
}

.metric {
  min-height: 105px;
  padding: 18px;
  display: grid;
  align-content: center;
  gap: 6px;
  border-right: 1px solid var(--line);
}

.metric:last-child { border-right: 0; }
.metric span { color: var(--muted); font-size: 12px; }
.metric strong { font-size: 25px; }

.admin-section { margin-top: 32px; }
.admin-search { width: min(360px, 100%); margin-bottom: 14px; }

.learner-list,
.course-ranking {
  border: 1px solid var(--line);
  background: var(--surface);
}

.learner-row,
.ranking-row {
  min-height: 64px;
  padding: 12px 15px;
  display: grid;
  align-items: center;
  gap: 16px;
  border-bottom: 1px solid var(--line);
}

.learner-row:last-child,
.ranking-row:last-child { border-bottom: 0; }

.learner-row { grid-template-columns: minmax(160px, 1fr) 90px 90px minmax(120px, 180px); }
.learner-identity { min-width: 0; display: flex; align-items: center; gap: 10px; }
.learner-identity > div:last-child { min-width: 0; display: grid; gap: 2px; }
.learner-identity strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.learner-identity span,
.learner-value span { color: var(--muted); font-size: 11px; }
.learner-value { display: grid; gap: 2px; }
.learner-value strong { font-size: 15px; }

.mini-progress { height: 6px; overflow: hidden; border-radius: 3px; background: #e6ebe9; }
.mini-progress span { display: block; height: 100%; border-radius: inherit; background: var(--brand); }

.ranking-row { grid-template-columns: minmax(0, 1fr) 90px minmax(120px, 200px); }
.ranking-row strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ranking-row > span { color: var(--muted); font-size: 12px; text-align: right; }

.empty-state {
  min-height: 240px;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 8px;
  color: var(--muted);
  text-align: center;
}

.empty-state svg { width: 30px; height: 30px; }
.empty-state strong { color: var(--text); }

.sync-warning {
  margin: 14px 42px 0;
  padding: 10px 13px;
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid #ead5ae;
  background: #fff9ee;
  color: #75501c;
  font-size: 12px;
}

.sync-warning svg { width: 16px; height: 16px; flex: 0 0 auto; }

.icon-button {
  width: 38px;
  height: 38px;
  padding: 0;
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
  cursor: pointer;
}

.icon-button:hover { background: var(--surface-soft); }
.icon-button svg { width: 18px; height: 18px; }
.icon-button.small { width: 28px; height: 28px; border: 0; background: transparent; }
.icon-button.small svg { width: 16px; height: 16px; }

.primary-button,
.secondary-button,
.complete-button {
  min-height: 44px;
  padding: 0 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: 7px;
  cursor: pointer;
  text-decoration: none;
  font-weight: 650;
}

.primary-button { border: 1px solid var(--brand); color: #ffffff; background: var(--brand); }
.primary-button:hover { background: var(--brand-dark); }
.secondary-button { border: 1px solid var(--line); background: var(--surface); }
.complete-button { border: 1px solid var(--brand); color: var(--brand-dark); background: var(--brand-soft); }
.complete-button.completed { color: #ffffff; background: var(--brand); }
.primary-button svg,
.secondary-button svg,
.complete-button svg { width: 18px; height: 18px; }

.course-dialog {
  width: min(560px, calc(100vw - 28px));
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  box-shadow: var(--shadow);
}

.course-dialog::backdrop { background: rgba(18, 28, 25, 0.54); }
.course-dialog article { background: var(--surface); }
.dialog-header { padding: 16px 18px 0; display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.dialog-body { padding: 10px 22px 22px; }
.dialog-body h2 { margin: 6px 0 8px; font-size: 22px; line-height: 1.35; overflow-wrap: anywhere; }
.course-meta { margin: 0; color: var(--muted); }
.topic-list { margin-top: 14px; display: flex; flex-wrap: wrap; gap: 7px; }
.topic-pill { padding: 5px 8px; border-radius: 5px; background: var(--blue-soft); color: #2b568f; font-size: 11px; }
.dialog-actions { margin-top: 24px; display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.completion-actions { margin-top: 10px; display: grid; grid-template-columns: 120px 1fr; gap: 10px; }

.login-gate {
  min-height: 100vh;
  padding: 24px;
  display: grid;
  place-items: center;
  background: var(--bg);
}

.login-panel {
  width: min(380px, 100%);
  padding: 32px;
  display: grid;
  justify-items: start;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.login-panel h1 { margin: 18px 0 5px; font-size: 24px; }
.login-panel p { margin: 0 0 24px; color: var(--muted); }

.loading {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: rgba(244, 246, 245, 0.92);
}

.loading span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--brand);
  animation: pulse 900ms infinite ease-in-out;
}

.loading span:nth-child(2) { animation-delay: 120ms; }
.loading span:nth-child(3) { animation-delay: 240ms; }

@keyframes pulse {
  0%, 100% { opacity: 0.25; transform: translateY(0); }
  50% { opacity: 1; transform: translateY(-4px); }
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  z-index: 120;
  max-width: min(420px, calc(100vw - 28px));
  padding: 11px 15px;
  border-radius: 7px;
  color: #ffffff;
  background: #24312d;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 10px);
  transition: opacity 160ms ease, transform 160ms ease;
}

.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 980px) {
  .course-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .path-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .progress-band { grid-template-columns: 130px minmax(150px, 1fr); }
  .progress-stats { grid-column: 1 / -1; }
  .admin-metrics { grid-template-columns: repeat(2, 1fr); }
  .metric:nth-child(2) { border-right: 0; }
  .metric:nth-child(-n + 2) { border-bottom: 1px solid var(--line); }
}

@media (max-width: 720px) {
  body { background: #ffffff; }
  .app { display: block; min-height: 100dvh; }
  .sidebar { display: none; }
  .workspace { min-height: 100dvh; }
  .mobile-header {
    position: sticky;
    top: 0;
    z-index: 30;
    height: 60px;
    padding: max(10px, env(safe-area-inset-top)) 15px 10px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(255, 255, 255, 0.96);
    border-bottom: 1px solid var(--line);
  }
  .brand.compact .brand-badge { width: 31px; height: 31px; flex-basis: 31px; font-size: 16px; }
  .content { width: 100%; padding: 22px 15px calc(88px + env(safe-area-inset-bottom)); }
  .mobile-nav {
    position: fixed;
    inset: auto 0 0;
    z-index: 40;
    min-height: 62px;
    padding: 5px 8px max(5px, env(safe-area-inset-bottom));
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: 1fr;
    background: rgba(255, 255, 255, 0.97);
    border-top: 1px solid var(--line);
  }
  .mobile-nav button {
    min-width: 0;
    min-height: 52px;
    display: grid;
    place-content: center;
    justify-items: center;
    gap: 3px;
    border: 0;
    background: transparent;
    color: #7b8581;
    font-size: 10px;
  }
  .mobile-nav svg { width: 20px; height: 20px; }
  .mobile-nav button.active { color: var(--brand); font-weight: 700; }
  .page-heading { margin-bottom: 18px; }
  .page-heading h1,
  .profile-header h1 { font-size: 23px; }
  .progress-band { margin: 0 -15px; padding: 20px 15px; grid-template-columns: 95px 1fr; gap: 16px; }
  .progress-copy strong { font-size: 28px; }
  .progress-stats { gap: 12px; }
  .progress-stats dd { font-size: 18px; }
  .content-section { margin-top: 28px; }
  .course-grid,
  .compact-grid { grid-template-columns: 1fr; gap: 10px; }
  .course-card { min-height: 144px; padding: 15px; }
  .path-grid { margin-right: -15px; padding-right: 15px; grid-template-columns: repeat(5, 142px); overflow-x: auto; scrollbar-width: none; }
  .path-grid::-webkit-scrollbar { display: none; }
  .path-button { min-height: 92px; }
  .profile-stats button { min-height: 78px; }
  .segmented { width: 100%; }
  .segmented button { min-width: 0; flex: 1; }
  .admin-metrics { grid-template-columns: repeat(2, 1fr); }
  .metric { min-height: 88px; padding: 14px; }
  .metric strong { font-size: 22px; }
  .learner-row { grid-template-columns: minmax(0, 1fr) 70px; gap: 10px; }
  .learner-row .learner-value:nth-child(3) { display: none; }
  .learner-row > div:last-child { grid-column: 1 / -1; }
  .ranking-row { grid-template-columns: minmax(0, 1fr) 70px; }
  .ranking-row .mini-progress { grid-column: 1 / -1; }
  .sync-warning { margin: 8px 15px 0; }
  .course-dialog {
    width: 100%;
    max-width: none;
    margin: auto 0 0;
    border-radius: 8px 8px 0 0;
  }
  .dialog-body { padding: 8px 18px calc(20px + env(safe-area-inset-bottom)); }
  .dialog-body h2 { font-size: 20px; }
  .dialog-actions { grid-template-columns: 1fr; }
  .completion-actions { grid-template-columns: 1fr 1fr; }
  .toast { bottom: calc(76px + env(safe-area-inset-bottom)); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; animation: none !important; }
}
