* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --bg: #f0f4f8;
  --card: #ffffff;
  --text: #1e293b;
  --muted: #64748b;
  --success: #16a34a;
  --danger: #dc2626;
  --border: #e2e8f0;
}

html {
  overflow-x: hidden;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
  max-width: 100vw;
}

img, svg, video, canvas {
  max-width: 100%;
  height: auto;
}

a {
  color: var(--primary);
  text-decoration: none;
}

/* 用户页横向锁定（管理员页不启用） */
html.page-user-lock {
  width: 100%;
  max-width: 100%;
}

body.page-user-lock {
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
  overscroll-behavior-x: none;
  touch-action: pan-y pinch-zoom;
  -webkit-overflow-scrolling: touch;
}

.app,
#app {
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
  min-height: 100vh;
  padding: 16px;
  overflow-x: hidden;
  box-sizing: border-box;
}

.app.app--user-lock,
#app.app--user-lock {
  max-width: 100%;
}

.card {
  background: var(--card);
  border-radius: 16px;
  padding: 24px;
  box-shadow: 0 4px 24px rgba(15, 23, 42, 0.06);
  margin-bottom: 16px;
  max-width: 100%;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.card-compact {
  padding: 16px 20px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 12px 24px;
  border: none;
  border-radius: 12px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

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

.btn-primary:hover:not(:disabled) {
  background: var(--primary-dark);
}

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

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

.btn-danger {
  color: var(--danger);
  border-color: var(--danger);
}

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

.btn-block {
  width: 100%;
}

.input, .select {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 15px;
  margin-bottom: 12px;
}

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

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

.nav {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.nav a, .nav button {
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 14px;
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--text);
  cursor: pointer;
  flex: 1 1 auto;
  min-width: 0;
  text-align: center;
}

.admin-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 16px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  flex-wrap: nowrap;
  padding-bottom: 4px;
  scrollbar-width: none;
}

.admin-tabs::-webkit-scrollbar {
  display: none;
}

.admin-tabs button,
.admin-tabs .tab {
  flex: 0 0 auto;
  white-space: nowrap;
  font-size: 13px;
  padding: 8px 12px;
}

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.page-header h3,
.page-header h4 {
  margin: 0;
  flex: 1 1 auto;
  min-width: 0;
  font-size: clamp(16px, 4.2vw, 20px);
  line-height: 1.4;
}

.toolbar {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  flex-wrap: wrap;
  align-items: stretch;
}

.toolbar .select {
  flex: 1 1 140px;
  margin-bottom: 0;
  min-width: 0;
}

.toolbar .btn {
  flex: 1 1 auto;
  min-width: fit-content;
}

.input-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: stretch;
  margin-bottom: 12px;
}

.input-row .input {
  flex: 1 1 160px;
  margin-bottom: 0;
  min-width: 0;
}

.input-row .btn {
  flex: 0 0 auto;
  white-space: nowrap;
  align-self: stretch;
}

.btn-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 8px;
}

.btn-row .btn {
  flex: 1 1 calc(50% - 4px);
  min-width: 0;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 8px 0;
}

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

.qr-actions .btn,
.qr-actions a {
  flex: 1 1 calc(50% - 4px);
  min-width: 0;
  text-align: center;
}

.table-wrap {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.table-wrap table {
  width: 100%;
}

.nav a.active, .nav a:hover {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.center-page {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 70vh;
  text-align: center;
}

/* 顶部导航（微信端） */
.nav-app {
  display: grid;
  grid-template-columns: 1fr 1fr 64px;
  gap: 8px;
  margin-bottom: 12px;
}

.nav-tab {
  padding: 10px 8px;
  border-radius: 10px;
  font-size: 14px;
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--text);
  cursor: pointer;
  text-align: center;
}

.nav-tab--active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.nav-exit-btn {
  padding: 10px 6px;
  border-radius: 10px;
  font-size: 13px;
  background: #fff;
  border: 1px solid #fecaca;
  color: #b91c1c;
  cursor: pointer;
}

/* 问卷测试首页 */
.test-home {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
}

.test-intro-card h3 {
  margin: 0;
  font-size: 16px;
  line-height: 1.4;
  flex: 1;
  min-width: 0;
}

.test-intro-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
}

.test-limit-chip {
  flex-shrink: 0;
  padding: 4px 10px;
  border-radius: 999px;
  background: #eff6ff;
  color: #1d4ed8;
  font-size: 12px;
  line-height: 1.4;
  white-space: nowrap;
}

.test-info-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.test-info-item {
  min-width: 0;
  padding: 10px 12px;
  border-radius: 10px;
  background: #f8fafc;
  border: 1px solid var(--border);
}

.test-info-item--full {
  grid-column: 1 / -1;
}

.test-info-label {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 4px;
}

.test-info-value {
  display: block;
  font-size: 14px;
  color: var(--text);
  line-height: 1.5;
  word-break: break-word;
}

.test-action {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding-top: 4px;
}

.test-action-tip {
  margin: 0;
  font-size: 13px;
  text-align: center;
}

.test-profile-card {
  width: 100%;
  max-width: 480px;
  text-align: left;
}

.test-profile-card h3 {
  font-size: 16px;
}

.start-btn {
  width: 200px;
  height: 200px;
  border-radius: 50%;
  font-size: 22px;
  background: linear-gradient(135deg, #2563eb, #7c3aed);
  color: #fff;
  border: none;
  cursor: pointer;
  box-shadow: 0 12px 40px rgba(37, 99, 235, 0.35);
  transition: transform 0.2s;
}

.start-btn--wechat {
  width: 100%;
  max-width: 100%;
  height: auto;
  min-height: 52px;
  border-radius: 14px;
  font-size: 18px;
  font-weight: 600;
  padding: 16px 20px;
  box-shadow: 0 8px 24px rgba(37, 99, 235, 0.28);
}

.start-btn--wechat:active:not(:disabled) {
  transform: scale(0.98);
}

.start-btn:hover:not(:disabled) {
  transform: scale(1.05);
}

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

.question-item {
  padding: 20px 0;
  border-bottom: 1px solid var(--border);
}

.question-item:last-child {
  border-bottom: none;
}

.question-title {
  font-weight: 600;
  margin-bottom: 12px;
  line-height: 1.6;
  overflow-wrap: anywhere;
}

.option span {
  flex: 1;
  min-width: 0;
  overflow-wrap: anywhere;
  line-height: 1.6;
  padding: 2px 0;
}

.option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  margin-bottom: 8px;
  cursor: pointer;
  border: 1px solid transparent;
  min-height: 44px;
}

.option:hover {
  background: #f8fafc;
}

.option.selected {
  background: #eff6ff;
  border-color: #93c5fd;
}

.option input {
  flex-shrink: 0;
  margin: 0;
  width: 18px;
  height: 18px;
}

.score-circle {
  width: 140px;
  height: 140px;
  border-radius: 50%;
  background: linear-gradient(135deg, #16a34a, #22c55e);
  color: #fff;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  margin: 0 auto 24px;
  font-size: 36px;
  font-weight: 700;
}

.wrong-item {
  border: 1px solid #fecaca;
  background: #fef2f2;
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 12px;
}

.wrong-item summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--danger);
}

.tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 12px;
  background: #e0e7ff;
  color: #3730a3;
}

.error {
  color: var(--danger);
  font-size: 14px;
  margin-bottom: 12px;
}

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

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  table-layout: fixed;
}

th, td {
  padding: 10px 8px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  overflow-wrap: anywhere;
  word-break: break-word;
  vertical-align: top;
}

.header-title {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 4px;
}

.tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.tab {
  flex: 1 1 calc(50% - 4px);
  min-width: 0;
  padding: 10px 8px;
  border: none;
  background: #f1f5f9;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  line-height: 1.3;
}

.tab.active {
  background: var(--primary);
  color: #fff;
}

.section-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--primary);
  padding: 16px 0 8px;
  margin-top: 8px;
  border-bottom: 2px solid #dbeafe;
}

.section-title:first-child {
  margin-top: 0;
}

.correct-item {
  border: 1px solid #bbf7d0;
  background: #f0fdf4;
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 12px;
}

.correct-item summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--success);
}

.review-question {
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 16px;
}

.review-question-header {
  font-weight: 700;
  margin-bottom: 8px;
  font-size: 15px;
}

.review-stem {
  margin-bottom: 12px;
  line-height: 1.7;
  overflow-wrap: anywhere;
}

.review-options {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 12px;
}

.review-option {
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #fff;
  line-height: 1.6;
  overflow-wrap: anywhere;
}

.review-option--correct {
  border-color: #86efac;
  background: #f0fdf4;
}

.review-option--wrong-select {
  border-color: #fca5a5;
  background: #fef2f2;
}

.review-option--selected.review-option--correct {
  border-color: #22c55e;
}

.review-tag {
  display: inline-block;
  margin-left: 8px;
  font-size: 12px;
  color: var(--muted);
}

.review-answer {
  padding-top: 10px;
  border-top: 1px dashed var(--border);
  font-weight: 600;
}

.review-explanation {
  margin-top: 10px;
  padding: 12px;
  border-radius: 8px;
  background: #fff7ed;
  color: #9a3412;
  font-size: 14px;
  line-height: 1.7;
}

.history-list {
  display: flex;
  flex-direction: column;
}

.history-header,
.history-row {
  display: grid;
  grid-template-columns: 1.3fr 0.85fr 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
}

.history-header {
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
  padding-top: 0;
}

.history-row:last-child {
  border-bottom: none;
}

.history-cell {
  font-size: 14px;
  line-height: 1.5;
  word-break: break-word;
}

.history-cell-label {
  display: none;
}

@media (max-width: 480px) {
  .history-header {
    display: none;
  }

  .history-row {
    grid-template-columns: 1fr;
    gap: 6px;
    padding: 16px 0;
  }

  .history-cell-label {
    display: block;
    font-size: 12px;
    color: var(--muted);
    margin-bottom: 2px;
  }
}

.qr-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
}

.qr-card {
  text-align: center;
  padding: 16px;
}

.qr-card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  font-size: 13px;
}

.qr-image {
  width: min(180px, 100%);
  height: auto;
  aspect-ratio: 1;
  margin: 0 auto 12px;
  display: block;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  object-fit: contain;
}

.qr-create-toolbar,
.qr-consult-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  justify-content: center;
  margin: 12px 0;
}

.qr-consult-row .input {
  max-width: 200px;
  flex: 1 1 160px;
}

.consult-add-form {
  display: grid;
  gap: 12px;
  margin-bottom: 20px;
  padding: 16px;
  border: 1px dashed var(--border);
  border-radius: 8px;
  background: var(--bg-soft, #f8fafc);
}

.consult-form-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.consult-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
}

.consult-card {
  text-align: center;
  padding: 16px;
}

.consult-preview {
  width: min(180px, 100%);
  height: auto;
  margin: 0 auto 12px;
  display: block;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  object-fit: contain;
}

.cell-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

@media (max-width: 768px) {
  .app {
    padding: 12px;
  }

  .card {
    padding: 16px;
    border-radius: 14px;
  }

  .header-title {
    font-size: 18px;
  }

  .start-btn {
    width: min(160px, 70vw);
    height: min(160px, 70vw);
    font-size: 18px;
  }

  .score-circle {
    width: 120px;
    height: 120px;
    font-size: 30px;
  }

  .section-title {
    font-size: 15px;
  }

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

  .qr-card-head {
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
  }

  .nav a, .nav button {
    flex: 1 1 calc(50% - 4px);
  }

  .nav-app {
    grid-template-columns: 1fr 1fr 58px;
    gap: 6px;
  }

  .nav-tab,
  .nav-exit-btn {
    font-size: 13px;
    padding: 9px 6px;
  }

  .test-info-grid {
    grid-template-columns: 1fr;
  }

  .test-info-item:not(.test-info-item--full) {
    grid-column: 1 / -1;
  }

  .responsive-table thead {
    display: none;
  }

  .responsive-table tbody tr {
    display: block;
    margin-bottom: 12px;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: #fafbfc;
  }

  .responsive-table tbody td {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    padding: 8px 0;
    border-bottom: 1px solid #f1f5f9;
    text-align: right;
  }

  .responsive-table tbody td:last-child {
    border-bottom: none;
  }

  .responsive-table tbody td::before {
    content: attr(data-label);
    font-weight: 600;
    color: var(--muted);
    font-size: 12px;
    text-align: left;
    flex: 0 0 auto;
    max-width: 42%;
  }

  .responsive-table tbody td.cell-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .responsive-table tbody td.cell-actions::before {
    margin-bottom: 4px;
  }

  .responsive-table tbody td.cell-actions .btn {
    width: 100%;
  }
}

@media (max-width: 480px) {
  .app {
    padding: 10px;
  }

  .card {
    padding: 14px;
  }

  .btn {
    padding: 11px 16px;
    font-size: 15px;
  }

  .tab {
    flex: 1 1 100%;
    font-size: 13px;
  }

  .toolbar .btn,
  .toolbar .select {
    flex: 1 1 100%;
  }

  .qr-actions .btn,
  .qr-actions a {
    flex: 1 1 100%;
  }

  .btn-row .btn {
    flex: 1 1 100%;
  }
}

.score-level {
  font-size: 18px;
  font-weight: 700;
  margin: 8px 0 12px;
}

.score-level--fail {
  color: var(--danger);
}

.score-level--primary {
  color: #2563eb;
}

.score-level--intermediate {
  color: #7c3aed;
}

.score-level--advanced {
  color: var(--success);
}

.result-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 16px;
}

.result-actions .btn {
  min-width: 120px;
}

.score-wechat {
  margin: 12px auto 16px;
  padding-top: 12px;
  border-top: 1px dashed var(--border);
  max-width: 240px;
}

.score-wechat-label {
  font-size: 14px;
  color: var(--muted);
  margin-bottom: 8px;
}

.score-wechat-qr {
  width: min(220px, 72vw);
  height: auto;
  display: block;
  margin: 0 auto;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #fff;
}

.role-select-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 8px;
}

.role-select-card {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
  background: #fff;
}

.role-select-card.selected {
  border-color: var(--primary);
  background: #eff6ff;
}

.role-select-card input {
  margin-top: 4px;
}

.role-select-title {
  font-weight: 600;
  margin-bottom: 4px;
}

.role-select-meta {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.5;
}

.image-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(15, 23, 42, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.image-modal-content {
  background: var(--card);
  border-radius: 16px;
  padding: 20px;
  max-width: min(320px, 92vw);
  width: 100%;
  text-align: center;
  box-shadow: 0 20px 50px rgba(15, 23, 42, 0.25);
}

.image-modal-img {
  width: min(260px, 100%);
  height: auto;
  display: block;
  margin: 0 auto 16px;
  border-radius: 8px;
  border: 1px solid var(--border);
}

.image-modal-close {
  width: 100%;
}

.rank-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 4px;
}

.rank-my-rank {
  margin: 0 0 8px;
  font-size: 15px;
  color: var(--text);
}

/* 柱状图共用纵轴与网格线 */
.chart-yaxis {
  width: 36px;
  padding-right: 6px;
  box-sizing: border-box;
  flex-shrink: 0;
}

.hist-chart .chart-yaxis,
.hist-chart-panel {
  display: table-cell;
  vertical-align: top;
}

.chart-yplot {
  position: relative;
}

.chart-ytick {
  position: absolute;
  right: 0;
  font-size: 11px;
  line-height: 1;
  color: var(--muted);
  text-align: right;
  -webkit-transform: translateY(-50%);
  transform: translateY(-50%);
}

.chart-gridlines {
  position: absolute;
  left: 0;
  right: 0;
  pointer-events: none;
}

.chart-gridline {
  position: absolute;
  left: 0;
  right: 0;
  border-top: 1px dashed #e2e8f0;
}

/* 测试成绩柱状图 */
.hist-chart-wrap {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px dashed var(--border);
  width: 100%;
  max-width: 100%;
  overflow: hidden;
}

.hist-chart-title {
  margin: 0 0 12px;
  font-size: 14px;
  color: var(--muted);
}

.hist-chart {
  display: table;
  table-layout: fixed;
  width: 100%;
  max-width: 100%;
  border-collapse: collapse;
  overflow: hidden;
}

.hist-chart-panel {
  position: relative;
  overflow: hidden;
  min-width: 0;
}

.hist-chart-viewport {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  box-sizing: border-box;
}

.hist-chart-plotrow,
.hist-chart-labelrow {
  font-size: 0;
  white-space: nowrap;
  min-width: 100%;
  box-sizing: border-box;
}

.hist-chart-plotrow {
  overflow: visible;
  padding: 0 4px;
}

.hist-chart-labelrow {
  padding: 6px 4px 0;
}

.hist-chart-col {
  display: inline-block;
  vertical-align: bottom;
  width: 64px;
  height: 100%;
  position: relative;
  font-size: 11px;
  white-space: normal;
  text-align: center;
}

.hist-chart-barouter {
  position: absolute;
  left: 50%;
  bottom: 0;
  width: 34px;
  margin-left: -17px;
}

.hist-chart-val {
  position: absolute;
  bottom: 100%;
  left: 50%;
  -webkit-transform: translateX(-50%);
  transform: translateX(-50%);
  font-size: 10px;
  font-weight: 600;
  line-height: 1.2;
  margin-bottom: 2px;
  color: var(--text);
  white-space: nowrap;
}

.hist-chart-val--in {
  bottom: auto;
  top: 4px;
  margin-bottom: 0;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
}

.hist-chart-bar {
  width: 100%;
  height: 100%;
  min-height: 2px;
  background: linear-gradient(180deg, #4ade80, #16a34a);
  border-radius: 6px 6px 2px 2px;
  box-shadow: 0 0 0 2px rgba(22, 163, 74, 0.2);
}

.hist-chart-xlabel {
  display: inline-block;
  vertical-align: top;
  width: 64px;
  font-size: 10px;
  line-height: 1.3;
  color: var(--muted);
  word-break: break-all;
  text-align: center;
  white-space: normal;
  box-sizing: border-box;
  padding: 0 2px;
}

.rank-header h3 {
  margin: 0;
}

.rank-hint {
  font-size: 13px;
  margin-bottom: 12px;
}

.rank-chart {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
  width: 100%;
  max-width: 100%;
  overflow: hidden;
}

.rank-chart-body {
  position: relative;
  flex: 1;
  min-width: 0;
  overflow: hidden;
}

.rank-chart-scroll {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 1;
  box-sizing: border-box;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
}

.rank-plot-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  min-width: min-content;
  padding: 0 4px;
  overflow: visible;
}

.rank-names-row {
  display: flex;
  gap: 8px;
  min-width: min-content;
  padding: 6px 4px 0;
  box-sizing: border-box;
}

.rank-bar-col {
  flex: 0 0 auto;
  width: 52px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
}

.rank-bar-outer {
  position: relative;
  width: 36px;
  min-height: 2px;
  flex-shrink: 0;
}

.rank-bar {
  width: 100%;
  height: 100%;
  min-height: 2px;
  background: linear-gradient(180deg, #60a5fa, #2563eb);
  border-radius: 6px 6px 2px 2px;
  transition: height 0.3s ease;
}

.rank-bar--self {
  background: linear-gradient(180deg, #4ade80, #16a34a);
  box-shadow: 0 0 0 2px rgba(22, 163, 74, 0.25);
}

.rank-bar-value {
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  font-size: 10px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  line-height: 1.2;
  margin-bottom: 2px;
  pointer-events: none;
}

.rank-bar-value--inside {
  bottom: auto;
  top: 4px;
  margin-bottom: 0;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
}

.rank-bar-name {
  flex: 0 0 auto;
  width: 52px;
  font-size: 11px;
  color: var(--muted);
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  line-height: 1.2;
}

.rank-bar-name--self {
  color: var(--success);
  font-weight: 700;
}

.rank-x-hint {
  text-align: center;
  font-size: 12px;
  color: var(--muted);
  margin-top: 4px;
}

@media (max-width: 480px) {
  .chart-yaxis {
    width: 32px;
  }

  .chart-ytick {
    font-size: 10px;
  }

  .rank-bar-col,
  .rank-bar-name {
    width: 44px;
  }

  .rank-bar-outer {
    width: 28px;
  }

  .rank-bar-value {
    font-size: 9px;
  }

  .rank-bar-name {
    font-size: 10px;
  }

  .hist-chart-col,
  .hist-chart-xlabel {
    width: 54px;
  }

  .hist-chart-barouter {
    width: 28px;
    margin-left: -14px;
  }
}

/* 用户管理 */
.user-mgmt-header {
  margin-bottom: 16px;
}

.user-mgmt-header h3 {
  margin: 0 0 6px;
  font-size: clamp(16px, 4.2vw, 20px);
}

.user-mgmt-desc {
  margin: 0;
  font-size: 13px;
  line-height: 1.5;
}

.user-mgmt-list {
  display: grid;
  gap: 12px;
}

.user-mgmt-card {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
  background: #fff;
}

.user-mgmt-card--inactive {
  opacity: 0.72;
  background: #f8fafc;
}

.user-mgmt-card--editing {
  border-color: var(--primary, #2563eb);
  box-shadow: 0 0 0 1px var(--primary, #2563eb);
}

.user-mgmt-card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.user-mgmt-name {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
}

.user-mgmt-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.user-tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  line-height: 1.5;
}

.user-tag--role {
  background: #eff6ff;
  color: #1d4ed8;
}

.user-tag--active {
  background: #ecfdf5;
  color: #047857;
}

.user-tag--inactive {
  background: #fef2f2;
  color: #b91c1c;
}

.user-mgmt-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.btn-sm {
  padding: 4px 10px !important;
  font-size: 12px !important;
}

.user-mgmt-meta {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px 16px;
}

.user-meta-item {
  min-width: 0;
}

.user-meta-label {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 2px;
}

.user-meta-value {
  display: block;
  font-size: 14px;
  color: var(--text);
  word-break: break-word;
}

.user-edit-panel {
  background: #f8fafc;
  margin-bottom: 16px;
  padding: 16px;
}

.user-edit-panel--inline {
  margin: 12px 0 0;
  padding: 12px 0 0;
  background: transparent;
  border-top: 1px solid var(--border, #e2e8f0);
}

.user-edit-panel h4 {
  margin: 0 0 12px;
}

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

.user-edit-grid .label {
  margin-top: 0;
}

@media (max-width: 640px) {
  .user-mgmt-meta,
  .user-edit-grid {
    grid-template-columns: 1fr;
  }

  .user-mgmt-actions {
    width: 100%;
  }

  .user-mgmt-actions .btn {
    flex: 1;
  }
}
