:root {
  --bg: #f3f4f6;
  --bg-accent: #eef2ff;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --text: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --primary: #2563eb;
  --primary-strong: #1d4ed8;
  --success: #16a34a;
  --warning: #f59e0b;
  --danger: #dc2626;
  --shadow: 0 10px 30px rgba(15, 23, 42, 0.08);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  min-height: 100vh;
  font-family: "Manrope", "Segoe UI", sans-serif;
  color: var(--text);
  background:
    radial-gradient(1000px 500px at 10% -20%, var(--bg-accent) 0%, transparent 60%),
    radial-gradient(700px 400px at 90% -30%, #dbeafe 0%, transparent 55%),
    var(--bg);
}

.app-shell {
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  position: sticky;
  top: 12px;
  z-index: 20;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 14px 18px;
  margin-bottom: 18px;
  border: 1px solid rgba(226, 232, 240, 0.9);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(8px);
  box-shadow: var(--shadow);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  color: var(--text);
  text-decoration: none;
}

.brand-logo {
  width: 28px;
  height: 28px;
  object-fit: contain;
  border-radius: 6px;
}

.brand-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--primary), #60a5fa);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.app-layout {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  gap: 18px;
  flex: 1 0 auto;
}

.sidebar {
  position: sticky;
  top: 96px;
  z-index: 5;
  align-self: start;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(8px);
  box-shadow: var(--shadow);
}

.sidebar-title {
  margin: 0 0 12px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.nav-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.nav-link {
  display: flex;
  position: relative;
  z-index: 1;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 12px;
  color: var(--text);
  text-decoration: none;
  border: 1px solid transparent;
  font-weight: 600;
}

.nav-link:hover {
  background: var(--surface-soft);
  border-color: var(--line);
}

.nav-link.active {
  background: #e0e7ff;
  border-color: #c7d2fe;
  color: #1e3a8a;
}

.app-main {
  min-width: 0;
}

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

  .sidebar {
    position: static;
  }
}

.user-pill {
  padding: 7px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: 13px;
  background: var(--surface-soft);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid transparent;
  border-radius: 12px;
  padding: 9px 14px;
  font-size: 14px;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn:focus-visible {
  outline: 2px solid rgba(37, 99, 235, 0.3);
  outline-offset: 2px;
}

.btn-primary {
  background: var(--primary);
  color: #fff !important;
}

.btn-primary:hover {
  background: var(--primary-strong);
  color: #fff !important;
}

.btn-primary:visited,
.btn-primary:active,
.btn-primary:focus {
  color: #fff !important;
}

.btn-ghost {
  border-color: var(--line);
  background: var(--surface);
  color: var(--text);
}

.btn-ghost:hover {
  border-color: #cbd5e1;
  background: var(--surface-soft);
}

.btn-danger {
  border-color: #fecaca;
  background: #fff1f2;
  color: #be123c;
}

.btn-danger:hover {
  background: #ffe4e6;
}

.page-head {
  margin: 6px 0 18px;
}

.page-title {
  margin: 0;
  font-size: clamp(24px, 4vw, 34px);
  line-height: 1.1;
  letter-spacing: -0.02em;
}

.page-subtitle {
  margin: 8px 0 0;
  color: var(--muted);
}

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

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
}

.card-body {
  padding: 18px;
}

.card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  min-width: 0;
}

.card-title {
  margin: 0;
  font-size: 18px;
  min-width: 0;
}

.card-title a {
  text-decoration: none;
  color: var(--text);
}

.card-title a:hover {
  color: var(--primary);
}
.card-head-main {
  flex: 1 1 auto;
  min-width: 0;
}

.card-head-main .card-title,
.card-head-main .card-title a,
.card-head-main .card-title span {
  overflow-wrap: anywhere;
  word-break: break-word;
}


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

.status {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 5px 10px;
  border-radius: 999px;
  font-size: clamp(11px, 0.78rem, 12px);
  font-weight: 700;
  line-height: 1.1;
  white-space: nowrap !important;
  word-break: keep-all !important;
  overflow-wrap: normal !important;
  flex: none;
  flex-shrink: 0;
  width: max-content;
  max-width: none;
  min-width: fit-content;
}

.profile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin-top: 14px;
}

.profile-grid-wide {
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
}

.profile-item {
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
}

.profile-label {
  display: block;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-bottom: 6px;
}

.profile-value {
  font-weight: 700;
}

.status-neutral {
  background: #f1f5f9;
  color: #475569;
}

.status-progress {
  background: #fff7ed;
  color: #b45309;
}

.status-ok {
  background: #ecfdf3;
  color: #15803d;
}

.status-bad {
  background: #fef2f2;
  color: #b91c1c;
}

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

.metric {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  background: var(--surface-soft);
}

.metric-label {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
}

.metric-value {
  margin: 4px 0 0;
  font-size: 18px;
  font-weight: 800;
}

.list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.list-item {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
  background: var(--surface-soft);
}

.list-item + .list-item {
  margin-top: 10px;
}

.lesson-meta {
  display: flex;
  flex: 0 0 auto;
  flex-wrap: nowrap;
  justify-content: flex-end;
  align-items: center;
  gap: 8px;
  margin-top: 0;
  margin-left: auto;
  min-width: max-content;
  white-space: nowrap;
}

.empty {
  text-align: center;
  border: 1px dashed #cbd5e1;
  border-radius: 14px;
  padding: 24px;
  color: var(--muted);
  background: rgba(248, 250, 252, 0.8);
}

.content-block {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px;
  background: var(--surface-soft);
  line-height: 1.7;
  min-width: 0;
  overflow-x: auto;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.content-block h1,
.content-block h2,
.content-block h3,
.content-block h4 {
  margin: 0 0 12px;
  line-height: 1.3;
}

.content-block p,
.content-block ul,
.content-block ol,
.content-block table,
.content-block blockquote {
  margin: 0 0 12px;
}

.content-block ul,
.content-block ol {
  padding-left: 22px;
}

.content-block img {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 0 auto;
  border-radius: 10px;
}

.content-block table {
  display: block;
  width: 100%;
  max-width: 100%;
  border-collapse: collapse;
  border: 1px solid var(--line);
  background: #fff;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.content-block th,
.content-block td {
  border: 1px solid var(--line);
  padding: 8px 10px;
  text-align: left;
  min-width: 120px;
  white-space: normal;
  overflow-wrap: anywhere;
}

.content-block pre,
.content-block code,
.content-block iframe,
.content-block video {
  max-width: 100%;
}

.content-block pre {
  overflow-x: auto;
}

.alert {
  border-radius: 12px;
  padding: 12px 14px;
  border: 1px solid transparent;
}

.alert-danger {
  border-color: #fecaca;
  background: #fef2f2;
  color: #b91c1c;
}

.alert-success {
  border-color: #bbf7d0;
  background: #f0fdf4;
  color: #166534;
}

.alert-neutral {
  border-color: var(--line);
  background: var(--surface-soft);
  color: var(--text);
}

.question {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
  background: var(--surface-soft);
}

.question legend {
  font-weight: 700;
  padding: 0 6px;
}

.option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
}

.option input {
  accent-color: var(--primary);
}

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

.login-wrap {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  padding: 20px;
}

.login-card {
  width: min(460px, 100%);
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: var(--shadow);
  padding: 24px;
}

.site-footer {
  margin-top: 20px;
  width: 100%;
  display: flex;
  justify-content: center;
}

.site-footer-image {
  display: block;
  width: min(100%, 1200px);
  height: auto;
  object-fit: contain;
  border-radius: 16px;
  box-shadow: var(--shadow);
}

.field {
  margin-top: 12px;
}

.field label {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 13px;
}

.field-help {
  margin: 8px 0 0;
  color: #94a3b8;
  font-size: 10px;
  line-height: 1.4;
}

.field input {
  width: 100%;
  border: 1px solid #cbd5e1;
  border-radius: 12px;
  padding: 11px 12px;
  font-size: 14px;
}

.field input:focus {
  border-color: var(--primary);
  outline: none;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.14);
}

.search-input {
  width: min(420px, 100%);
  border: 1px solid #cbd5e1;
  border-radius: 12px;
  padding: 11px 12px;
  font-size: 14px;
  background: #fff;
}

.search-input:focus {
  border-color: var(--primary);
  outline: none;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.14);
}

.muted mark {
  background: #fef3c7;
  color: inherit;
  border-radius: 4px;
  padding: 0 2px;
}

.kb-tree .card {
  overflow: hidden;
}

.kb-section,
.kb-module {
  border: 1px solid #d9e3f3;
  border-radius: 18px;
  background: #f8fbff;
  overflow: hidden;
}

.kb-module {
  background: linear-gradient(180deg, #ffffff 0%, #fbfdff 100%);
  border-color: #d7e3f4;
  margin-left: 18px;
  box-shadow: inset 0 0 0 1px rgba(148, 163, 184, 0.04);
}

.kb-toggle {
  list-style: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px;
  font-weight: 800;
  color: var(--ink);
}

.kb-toggle::-webkit-details-marker {
  display: none;
}

.kb-toggle::after {
  content: "+";
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: #e2e8f0;
  color: var(--ink);
  flex: 0 0 auto;
}

.kb-section[open] > .kb-toggle::after,
.kb-module[open] > .kb-toggle::after {
  content: "-";
}

.kb-toggle-section {
  font-size: 24px;
  background: linear-gradient(90deg, #eef5ff 0%, #f8fbff 100%);
  border-bottom: 1px solid #dde8f8;
}

.kb-toggle-module {
  font-size: 18px;
  background: linear-gradient(90deg, #ffffff 0%, #f8fbff 100%);
  border-bottom: 1px solid #e5edf8;
}

.kb-panel {
  padding: 0 18px 18px;
  border-radius: 0 0 18px 18px;
}

.kb-articles {
  margin-top: 8px;
  padding-top: 10px;
  border-top: 1px dashed #d6e2f1;
}

.kb-article {
  margin: 0;
  border: 1px solid #e5edf8;
  border-radius: 16px;
  background: #fff;
  padding: 12px 14px;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.04);
  overflow: hidden;
}

.kb-article-label {
  margin: 0 0 6px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #64748b;
}

@media (max-width: 640px) {
  .card-head {
    flex-wrap: nowrap;
    align-items: flex-start;
  }

  .lesson-meta {
    gap: 6px;
  }

  .status {
    padding: 4px 8px;
    font-size: 11px;
  }

  .kb-module {
    margin-left: 0;
  }

  .app-shell {
    padding: 14px;
  }

  .topbar {
    top: 8px;
    padding: 12px;
  }

  .user-pill {
    display: none;
  }

  .metric-grid {
    grid-template-columns: 1fr;
  }
}

.payment-history-wrap {
  margin-top: 14px;
  overflow-x: auto;
}

.payment-history-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  min-width: 760px;
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
  background: var(--surface);
}

.payment-history-table th,
.payment-history-table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

.payment-history-table thead th {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  background: var(--surface-soft);
}

.payment-history-table tbody tr:last-child td {
  border-bottom: 0;
}


.app-main,
.app-main * {
  -webkit-user-select: none;
  user-select: none;
}

.app-main input,
.app-main textarea,
.app-main select,
.app-main button,
.app-main a,
.app-main label {
  -webkit-user-select: auto;
  user-select: auto;
}
