/* =========================================================
   内部站样式（本地自包含，无外部字体/图片/CDN）
   - 浅色 / 深色两套变量，跟随 prefers-color-scheme
   - 响应式：桌面与手机均有良好阅读体验
   ========================================================= */

:root {
  --font-sans: system-ui, -apple-system, "Segoe UI", "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "Cascadia Code", Consolas, "Liberation Mono", monospace;

  --bg: #f4f6fa;
  --bg-elevated: #ffffff;
  --surface: #ffffff;
  --surface-soft: #f8fafd;
  --border: #e4e8f0;
  --border-strong: #d4dae6;
  --text: #101828;
  --text-muted: #5b6678;
  --text-faint: #8791a3;

  --primary: #335dfb;
  --primary-hover: #2449d8;
  --primary-soft: #edf1ff;
  --primary-contrast: #ffffff;
  --accent: #7c5cff;

  --danger: #d64545;
  --danger-hover: #b93636;
  --danger-soft: #fdeeee;
  --ok: #15803d;
  --ok-soft: #e9f8ef;
  --warn: #b45309;
  --warn-soft: #fef3e2;

  --shadow-1: 0 1px 2px rgba(16, 24, 40, 0.05);
  --shadow-2: 0 10px 34px -14px rgba(16, 24, 40, 0.2), 0 2px 8px rgba(16, 24, 40, 0.04);
  --shadow-3: 0 28px 60px -24px rgba(16, 24, 40, 0.3), 0 6px 18px rgba(16, 24, 40, 0.06);

  --radius-sm: 10px;
  --radius: 14px;
  --radius-lg: 20px;

  --ring: 0 0 0 3px rgba(51, 93, 251, 0.22);
  --topbar-bg: rgba(255, 255, 255, 0.82);
  --backdrop: saturate(160%) blur(12px);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b0e13;
    --bg-elevated: #12161d;
    --surface: #141922;
    --surface-soft: #1a2029;
    --border: #242c38;
    --border-strong: #313b4a;
    --text: #e9edf4;
    --text-muted: #a3adbf;
    --text-faint: #727f94;

    --primary: #6d8cff;
    --primary-hover: #8aa3ff;
    --primary-soft: #1c2743;
    --primary-contrast: #0a1020;
    --accent: #9d84ff;

    --danger: #f07171;
    --danger-hover: #ff8a8a;
    --danger-soft: #2b1a1e;
    --ok: #4ade80;
    --ok-soft: #12261a;
    --warn: #fbbf24;
    --warn-soft: #2b2112;

    --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.5);
    --shadow-2: 0 12px 36px -14px rgba(0, 0, 0, 0.7), 0 2px 8px rgba(0, 0, 0, 0.35);
    --shadow-3: 0 30px 70px -25px rgba(0, 0, 0, 0.8), 0 8px 20px rgba(0, 0, 0, 0.4);

    --ring: 0 0 0 3px rgba(109, 140, 255, 0.32);
    --topbar-bg: rgba(15, 19, 26, 0.78);
  }
}

* {
  box-sizing: border-box;
}

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

body.page {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

::selection {
  background: var(--primary);
  color: var(--primary-contrast);
}

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

a:hover {
  color: var(--primary-hover);
}

h1,
h2,
h3 {
  margin: 0;
  line-height: 1.3;
  letter-spacing: -0.01em;
}

img,
svg {
  max-width: 100%;
}

/* ------------------------------------------------------------ 通用组件 */

.container {
  width: 100%;
  max-width: 1080px;
  margin: 0 auto;
  padding: 32px 24px 56px;
  flex: 1;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: var(--surface-soft);
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.4;
  cursor: pointer;
  transition: background-color 0.16s ease, border-color 0.16s ease, color 0.16s ease,
    transform 0.08s ease, box-shadow 0.16s ease;
  user-select: none;
}

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

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

.btn:focus-visible {
  outline: none;
  box-shadow: var(--ring);
}

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

.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: var(--primary-contrast);
  border-color: transparent;
  box-shadow: 0 6px 16px -8px rgba(51, 93, 251, 0.6);
}

.btn-primary:hover {
  filter: brightness(1.05);
  border-color: transparent;
}

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

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

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

.btn-danger-ghost:hover {
  background: var(--danger-soft);
  border-color: transparent;
}

.btn-sm {
  padding: 6px 11px;
  font-size: 13px;
  border-radius: 8px;
}

.btn-block {
  width: 100%;
}

.input,
.textarea,
.select {
  width: 100%;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  font-size: 14.5px;
  line-height: 1.5;
  transition: border-color 0.16s ease, box-shadow 0.16s ease, background-color 0.16s ease;
}

.input::placeholder,
.textarea::placeholder {
  color: var(--text-faint);
}

.input:hover,
.textarea:hover {
  border-color: var(--border-strong);
}

.input:focus,
.textarea:focus,
.select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: var(--ring);
}

.textarea {
  resize: vertical;
  min-height: 108px;
}

.select {
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-faint) 50%),
    linear-gradient(135deg, var(--text-faint) 50%, transparent 50%);
  background-position: calc(100% - 18px) calc(50% - 2px), calc(100% - 13px) calc(50% - 2px);
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 34px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.field-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.01em;
}

.field-optional {
  font-weight: 400;
  color: var(--text-faint);
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  align-items: end;
}

.form-grid .form-actions {
  grid-column: 1 / -1;
  justify-content: flex-start;
}

.stack-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-top: 18px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-1);
}

.card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}

.card-title {
  font-size: 16px;
  font-weight: 650;
}

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

.link-more:hover {
  color: var(--primary);
}

.alert {
  display: block;
  padding: 11px 14px;
  margin-bottom: 18px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-soft);
  color: var(--text-muted);
  font-size: 14px;
}

.alert[hidden] {
  display: none;
}

.alert-error {
  border-color: rgba(214, 69, 69, 0.35);
  background: var(--danger-soft);
  color: var(--danger);
}

.alert-success {
  border-color: rgba(21, 128, 61, 0.35);
  background: var(--ok-soft);
  color: var(--ok);
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.7;
  white-space: nowrap;
}

.badge-admin {
  background: var(--primary-soft);
  color: var(--primary);
}

.badge-user {
  background: var(--surface-soft);
  color: var(--text-muted);
  border: 1px solid var(--border);
}

.badge-ok {
  background: var(--ok-soft);
  color: var(--ok);
}

.badge-disabled {
  background: var(--danger-soft);
  color: var(--danger);
}

.badge-pin {
  background: var(--warn-soft);
  color: var(--warn);
}

.badge-self {
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 11px;
}

.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary-soft), var(--surface-soft));
  border: 1px solid var(--border);
  color: var(--primary);
  font-size: 15px;
  font-weight: 700;
  text-transform: uppercase;
  user-select: none;
}

.avatar-sm {
  width: 30px;
  height: 30px;
  font-size: 13px;
}

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

.spinner {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid currentColor;
  border-top-color: transparent;
  animation: spin 0.7s linear infinite;
}

.spinner[hidden] {
  display: none;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ------------------------------------------------------------ 顶栏 */

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  background: var(--topbar-bg);
  -webkit-backdrop-filter: var(--backdrop);
  backdrop-filter: var(--backdrop);
  border-bottom: 1px solid var(--border);
}

.topbar-inner {
  max-width: 1080px;
  margin: 0 auto;
  padding: 12px 24px;
  display: flex;
  align-items: center;
  gap: 26px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-weight: 700;
  font-size: 16px;
  letter-spacing: -0.01em;
  flex: 0 0 auto;
}

.brand:hover {
  color: var(--text);
}

.brand-mark {
  position: relative;
  width: 28px;
  height: 28px;
  border-radius: 9px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  box-shadow: 0 4px 12px -4px rgba(51, 93, 251, 0.55);
}

.brand-mark::after {
  content: "";
  position: absolute;
  inset: 7px;
  border: 2px solid rgba(255, 255, 255, 0.92);
  border-radius: 3px;
}

.brand-mark-lg {
  width: 52px;
  height: 52px;
  border-radius: 15px;
}

.brand-mark-lg::after {
  inset: 13px;
  border-radius: 5px;
}

.brand-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 240px;
}

.nav {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: 1 1 auto;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: none;
}

.nav::-webkit-scrollbar {
  display: none;
}

.nav-link {
  padding: 7px 13px;
  border-radius: 999px;
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 550;
  white-space: nowrap;
  transition: background-color 0.16s ease, color 0.16s ease;
}

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

.nav-link-active {
  background: var(--primary-soft);
  color: var(--primary);
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 9px;
  flex: 0 0 auto;
}

.user-chip-name {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-muted);
  max-width: 130px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ------------------------------------------------------------ 页头 */

.page-head {
  margin: 4px 0 26px;
}

.eyebrow {
  margin: 0 0 6px;
  font-size: 12px;
  font-weight: 650;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--primary);
}

.page-title {
  font-size: clamp(24px, 3.4vw, 30px);
  font-weight: 750;
  letter-spacing: -0.02em;
}

.page-subtitle {
  margin: 8px 0 0;
  color: var(--text-muted);
  font-size: 14px;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.sub-dot {
  color: var(--text-faint);
}

/* ------------------------------------------------------------ 仪表盘 */

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 18px;
  margin-bottom: 22px;
}

.stat-card {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 20px 22px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: var(--shadow-1);
  position: relative;
  overflow: hidden;
}

.stat-card::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 3px;
  background: linear-gradient(180deg, var(--primary), var(--accent));
  opacity: 0.85;
}

.stat-label {
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 600;
}

.stat-value {
  font-size: 30px;
  font-weight: 750;
  letter-spacing: -0.03em;
  line-height: 1.3;
}

.stat-hint {
  font-size: 12px;
  color: var(--text-faint);
}

.grid-2 {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(0, 1fr);
  gap: 20px;
  align-items: start;
}

.recent-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.recent-item {
  display: flex;
  gap: 12px;
  padding: 12px 8px;
  border-radius: var(--radius-sm);
  transition: background-color 0.16s ease;
}

.recent-item:hover {
  background: var(--surface-soft);
}

.recent-main {
  min-width: 0;
  flex: 1;
}

.recent-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.recent-author {
  font-weight: 650;
  font-size: 14px;
}

.recent-time {
  font-size: 12px;
  color: var(--text-faint);
  margin-left: auto;
}

.recent-content {
  margin: 4px 0 0;
  color: var(--text-muted);
  font-size: 13.5px;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.empty-inline {
  padding: 26px 8px;
  text-align: center;
  color: var(--text-faint);
  font-size: 14px;
}

.quick-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
}

.quick-link {
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 13px 15px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface-soft);
  color: var(--text);
  transition: border-color 0.16s ease, transform 0.12s ease, box-shadow 0.16s ease;
}

.quick-link:hover {
  color: var(--text);
  border-color: var(--primary);
  box-shadow: var(--shadow-1);
  transform: translateY(-1px);
}

.quick-link-title {
  font-weight: 650;
  font-size: 14px;
}

.quick-link-desc {
  font-size: 12.5px;
  color: var(--text-faint);
}

.account-box {
  margin-top: 20px;
  padding-top: 18px;
  border-top: 1px dashed var(--border);
}

.account-box-flat {
  margin-top: 0;
  padding-top: 0;
  border-top: 0;
}

.account-title {
  font-size: 13px;
  font-weight: 650;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.account-list {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 6px 18px;
  margin: 0;
  font-size: 13.5px;
}

.account-list dt {
  color: var(--text-faint);
}

.account-list dd {
  margin: 0;
  color: var(--text);
  font-weight: 550;
  overflow-wrap: anywhere;
}

/* ------------------------------------------------------------ 留言板 */

.composer {
  margin-bottom: 20px;
}

.composer .card-title {
  margin-bottom: 14px;
}

.composer-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-top: 12px;
}

.char-count {
  font-size: 12.5px;
  color: var(--text-faint);
  font-variant-numeric: tabular-nums;
}

.char-count-warn {
  color: var(--danger);
}

.messages {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.msg-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 20px 20px;
  box-shadow: var(--shadow-1);
  transition: border-color 0.16s ease, box-shadow 0.16s ease;
}

.msg-card:hover {
  box-shadow: var(--shadow-2);
}

.msg-pinned {
  border-color: rgba(180, 83, 9, 0.35);
  background: linear-gradient(180deg, var(--warn-soft), var(--surface) 90px);
}

.msg-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.msg-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
  flex-wrap: wrap;
}

.msg-author {
  font-weight: 650;
  font-size: 14px;
}

.msg-time {
  font-size: 12px;
  color: var(--text-faint);
}

.msg-actions {
  display: flex;
  gap: 2px;
  flex: 0 0 auto;
}

.msg-body {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
  font-size: 14.5px;
  line-height: 1.75;
  color: var(--text);
}

.empty-state {
  padding: 54px 20px;
  text-align: center;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-lg);
  background: var(--surface);
}

.empty-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 20px;
  margin-bottom: 12px;
}

.empty-title {
  font-size: 16px;
  font-weight: 650;
}

.empty-desc {
  margin: 6px 0 0;
  color: var(--text-faint);
  font-size: 13.5px;
}

.load-more-wrap {
  display: flex;
  justify-content: center;
  margin-top: 20px;
}

/* ------------------------------------------------------------ 成员管理 */

.member-list {
  padding-bottom: 10px;
}

.member-list-body {
  display: flex;
  flex-direction: column;
}

.member-row {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) auto 120px auto;
  gap: 16px;
  align-items: center;
  padding: 15px 6px;
  border-top: 1px solid var(--border);
}

.member-row:first-child {
  border-top: 0;
}

.member-main {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.member-id {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.member-name {
  font-weight: 650;
  font-size: 14.5px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.member-sub {
  font-size: 12.5px;
  color: var(--text-faint);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

.member-last {
  font-size: 12px;
  color: var(--text-faint);
  line-height: 1.5;
}

.member-last span {
  color: var(--text-muted);
}

.member-actions {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

/* ------------------------------------------------------------ 安全检查 */

.sec-rows {
  display: flex;
  flex-direction: column;
}

.sec-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 4px;
  border-top: 1px solid var(--border);
  font-size: 13.5px;
  min-width: 0;
}

.sec-row:first-child {
  border-top: 0;
}

.sec-row-value {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}

.sec-row-meta {
  margin-left: auto;
  flex: 0 0 auto;
  color: var(--text-faint);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.sec-rank {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 30px;
  height: 22px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--surface-soft);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 11.5px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
}

.sec-events-card {
  margin: 20px 0;
}

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

.sec-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.sec-table th {
  padding: 9px 10px;
  text-align: left;
  font-size: 12px;
  font-weight: 650;
  color: var(--text-faint);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.sec-table td {
  padding: 9px 10px;
  border-top: 1px solid var(--border);
  vertical-align: top;
  white-space: nowrap;
}

.sec-table tbody tr:first-child td {
  border-top: 0;
}

.sec-table tbody tr:hover {
  background: var(--surface-soft);
}

.sec-time {
  color: var(--text-faint);
  font-variant-numeric: tabular-nums;
}

.sec-ip {
  font-variant-numeric: tabular-nums;
}

.sec-event {
  font-weight: 600;
}

.sec-detail {
  color: var(--text-muted);
  white-space: normal;
  overflow-wrap: anywhere;
  min-width: 160px;
}

.sec-note {
  margin: 14px 0 0;
  line-height: 1.7;
}

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

.limit-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 14px;
  padding: 9px 0;
  border-top: 1px dashed var(--border);
  font-size: 13.5px;
}

.limit-row:first-child {
  border-top: 0;
}

.limit-key {
  color: var(--text-faint);
}

.limit-value {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

/* ------------------------------------------------------------ 登录页 */

.page-login {
  background:
    radial-gradient(1100px 520px at 12% -10%, var(--primary-soft), transparent 70%),
    radial-gradient(900px 520px at 92% 8%, var(--surface-soft), transparent 70%),
    var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 28px 16px;
}

.login-wrap {
  width: 100%;
  max-width: 420px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
}

.login-card {
  width: 100%;
  padding: 38px 36px 30px;
  border-radius: 24px;
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: var(--shadow-3);
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 13px;
  margin-bottom: 26px;
}

.login-brand-name {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.01em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.login-title {
  font-size: 25px;
  font-weight: 750;
  letter-spacing: -0.02em;
}

.login-subtitle {
  margin: 6px 0 22px;
  font-size: 13.5px;
  color: var(--text-muted);
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.login-form .btn-block {
  margin-top: 6px;
  padding: 12px 16px;
  font-size: 15px;
}

.login-hint {
  margin: 18px 0 0;
  font-size: 12px;
  color: var(--text-faint);
  text-align: center;
  line-height: 1.6;
}

.login-footer {
  margin: 0;
  font-size: 12px;
  color: var(--text-faint);
}

/* ------------------------------------------------------------ 错误页 */

.page-error {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 28px 16px;
  background:
    radial-gradient(900px 480px at 50% -20%, var(--primary-soft), transparent 70%),
    var(--bg);
}

.error-wrap {
  width: 100%;
  max-width: 460px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
}

.error-card {
  width: 100%;
  padding: 46px 34px;
  text-align: center;
  border-radius: 24px;
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: var(--shadow-3);
}

.error-code {
  display: inline-block;
  font-size: 44px;
  font-weight: 800;
  letter-spacing: -0.04em;
  line-height: 1;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.error-title {
  margin-top: 14px;
  font-size: 20px;
  font-weight: 700;
}

.error-desc {
  margin: 8px 0 22px;
  color: var(--text-muted);
  font-size: 14px;
}

/* ------------------------------------------------------------ 页脚 / Toast */

.site-footer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 22px 16px 30px;
  color: var(--text-faint);
  font-size: 12.5px;
}

.footer-dot {
  opacity: 0.6;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translateX(-50%) translateY(12px);
  z-index: 60;
  max-width: min(560px, 90vw);
  padding: 10px 18px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-2);
  font-size: 13.5px;
  opacity: 0;
  transition: opacity 0.2s ease, transform 0.2s ease;
  pointer-events: none;
}

.toast[hidden] {
  display: none;
}

.toast-visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ------------------------------------------------------------ 策略库 */

:root {
  --hm-up-1: rgba(21, 128, 61, 0.1);
  --hm-up-2: rgba(21, 128, 61, 0.24);
  --hm-up-3: rgba(21, 128, 61, 0.4);
  --hm-down-1: rgba(214, 69, 69, 0.1);
  --hm-down-2: rgba(214, 69, 69, 0.24);
  --hm-down-3: rgba(214, 69, 69, 0.4);
}

@media (prefers-color-scheme: dark) {
  :root {
    --hm-up-1: rgba(74, 222, 128, 0.14);
    --hm-up-2: rgba(74, 222, 128, 0.28);
    --hm-up-3: rgba(74, 222, 128, 0.46);
    --hm-down-1: rgba(240, 113, 113, 0.14);
    --hm-down-2: rgba(240, 113, 113, 0.28);
    --hm-down-3: rgba(240, 113, 113, 0.46);
  }
}

.badge-production {
  background: var(--ok-soft);
  color: var(--ok);
}

.badge-backtest {
  background: var(--surface-soft);
  color: var(--text-muted);
  border: 1px solid var(--border);
}

.badge-stale {
  background: var(--warn-soft);
  color: var(--warn);
}

.freshness {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  color: var(--text-faint);
}

.freshness::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-faint);
  flex: 0 0 auto;
}

.freshness-ok::before {
  background: var(--ok);
}

.freshness-warn::before {
  background: var(--warn);
}

.freshness-stale::before {
  background: var(--danger);
}

.strategy-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 18px;
}

.strategy-card {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 20px 22px 18px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: var(--shadow-1);
  color: var(--text);
  transition: border-color 0.16s ease, transform 0.12s ease, box-shadow 0.16s ease;
}

.strategy-card:hover {
  color: var(--text);
  border-color: var(--primary);
  box-shadow: var(--shadow-2);
  transform: translateY(-2px);
}

.strategy-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.strategy-name {
  margin: 0;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.35;
}

.strategy-desc {
  margin: 5px 0 0;
  color: var(--text-muted);
  font-size: 13px;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.strategy-spark {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  padding: 6px 0 0;
}

.strategy-spark svg {
  min-width: 0;
}

.strategy-note {
  font-size: 12.5px;
  color: var(--text-faint);
  white-space: nowrap;
}

.strategy-card-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px dashed var(--border);
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(112px, 1fr));
  gap: 10px 18px;
}

.metric {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}

.metric-label {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.metric-value {
  font-size: 20px;
  font-weight: 720;
  letter-spacing: -0.02em;
  line-height: 1.35;
  font-variant-numeric: tabular-nums;
}

.metric-value-sm {
  font-size: 15px;
  font-weight: 650;
}

.tone-pos {
  color: var(--ok);
}

.tone-neg {
  color: var(--danger);
}

.metric-hint {
  font-size: 11.5px;
  color: var(--text-faint);
}

.chart-card {
  padding-bottom: 18px;
}

.chart {
  display: block;
  width: 100%;
  height: auto;
}

.chart-bg {
  fill: transparent;
}

.chart-grid {
  stroke: var(--border);
  stroke-width: 1;
}

.chart-baseline {
  stroke: var(--border-strong);
  stroke-width: 1;
  stroke-dasharray: 4 4;
}

.chart-axis-text {
  fill: var(--text-faint);
  font-family: var(--font-sans);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.chart-line {
  fill: none;
  stroke: var(--primary);
  stroke-width: 2;
  stroke-linejoin: round;
}

.chart-area {
  fill: var(--primary-soft);
  opacity: 0.7;
}

.chart-dot {
  fill: var(--primary);
  stroke: var(--surface);
  stroke-width: 1.5;
}

.chart-dot-warn {
  fill: var(--danger);
}

.chart-drawdown-line {
  fill: none;
  stroke: var(--danger);
  stroke-width: 2;
  stroke-linejoin: round;
}

.chart-drawdown-area {
  fill: var(--danger-soft);
  opacity: 0.85;
}

.chart-bar {
  fill: var(--ok);
}

.chart-bar.down {
  fill: var(--danger);
}

.chart-bar.up {
  fill: var(--ok);
}

.chart-bar-label {
  fill: var(--text-muted);
  font-size: 10px;
}

.hm-cell {
  fill: transparent;
  stroke: var(--border);
  stroke-width: 1;
}

.hm-cell.hm-empty {
  stroke: transparent;
  fill: var(--surface-soft);
}

.hm-cell.hm-up-1 {
  fill: var(--hm-up-1);
}

.hm-cell.hm-up-2 {
  fill: var(--hm-up-2);
}

.hm-cell.hm-up-3 {
  fill: var(--hm-up-3);
}

.hm-cell.hm-down-1 {
  fill: var(--hm-down-1);
}

.hm-cell.hm-down-2 {
  fill: var(--hm-down-2);
}

.hm-cell.hm-down-3 {
  fill: var(--hm-down-3);
}

.hm-text {
  fill: var(--text);
  font-family: var(--font-sans);
  font-size: 11px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.sparkline {
  display: block;
  width: 120px;
  height: 34px;
  flex: 0 0 auto;
}

.sparkline-line {
  fill: none;
  stroke: var(--ok);
  stroke-width: 1.6;
}

.sparkline-line.down {
  stroke: var(--danger);
}

.chart-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 120px;
  border-radius: var(--radius);
  border: 1px dashed var(--border);
  background: var(--surface-soft);
  color: var(--text-faint);
  font-size: 14px;
}

.chart-empty-sm {
  min-height: 0;
  border: 0;
  background: transparent;
  padding: 0;
}

.rules-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.rules-list li {
  display: flex;
  gap: 10px;
  font-size: 13.5px;
  line-height: 1.55;
  color: var(--text-muted);
}

.rules-list li::before {
  content: "▸";
  color: var(--primary);
  flex: 0 0 auto;
}

.rules-list strong {
  color: var(--text);
  font-weight: 650;
}

.data-table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}

.data-table th {
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  padding: 0 10px 9px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.data-table td {
  padding: 9px 10px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.data-table tbody tr:hover td {
  background: var(--surface-soft);
}

.data-table .col-code {
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--text-muted);
}

.data-table .col-num {
  text-align: right;
}

.pick-badge {
  display: inline-flex;
  align-items: center;
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
}

.pick-badge-new {
  background: var(--primary-soft);
  color: var(--primary);
}

.pick-badge-hold {
  background: var(--surface-soft);
  color: var(--text-muted);
  border: 1px solid var(--border);
}

.pick-badge-exit {
  background: var(--warn-soft);
  color: var(--warn);
}

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

.history-item {
  display: grid;
  grid-template-columns: 108px minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  padding: 11px 4px;
  border-bottom: 1px solid var(--border);
  font-size: 13.5px;
}

.history-item:last-child {
  border-bottom: 0;
}

.history-date {
  font-variant-numeric: tabular-nums;
  color: var(--text);
  font-weight: 620;
}

.history-main {
  min-width: 0;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-tags {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.strategy-links {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  font-size: 13px;
}

.strategy-links a,
.strategy-links span {
  color: var(--text-muted);
}

.strategy-links a:hover {
  color: var(--primary);
}

.strategy-meta-line {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 8px;
  font-size: 13px;
  color: var(--text-muted);
}

.status-banner {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 16px;
  margin-bottom: 20px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface-soft);
  font-size: 13.5px;
  color: var(--text-muted);
}

.status-banner.tone-warn-banner {
  border-color: rgba(180, 83, 9, 0.35);
  background: var(--warn-soft);
  color: var(--warn);
}

.status-banner.tone-ok-banner {
  border-color: rgba(21, 128, 61, 0.3);
  background: var(--ok-soft);
  color: var(--ok);
}

.holdings-note {
  margin-top: 12px;
}

/* ------------------------------------------------------------ 响应式 */

@media (max-width: 900px) {
  .form-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

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

  .member-last {
    grid-column: 1 / 2;
  }

  .member-actions {
    grid-column: 2 / 3;
    grid-row: 1 / 3;
    flex-direction: column;
    align-items: stretch;
  }
}

@media (max-width: 680px) {
  .topbar-inner {
    flex-wrap: wrap;
    gap: 10px 14px;
    padding: 10px 16px;
    align-items: center;
  }

  .brand {
    order: 1;
  }

  .brand-name {
    max-width: 150px;
  }

  .user-chip {
    order: 2;
    margin-left: auto;
  }

  .user-chip-name {
    display: none;
  }

  .nav {
    order: 3;
    flex-basis: 100%;
    width: 100%;
    gap: 2px;
    padding-bottom: 2px;
  }

  .nav-link {
    padding: 6px 11px;
    font-size: 13.5px;
  }

  .container {
    padding: 20px 16px 42px;
  }

  .card {
    padding: 18px;
    border-radius: var(--radius);
  }

  .login-card {
    padding: 30px 22px 24px;
    border-radius: 20px;
  }

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

  .stat-grid {
    gap: 12px;
  }

  .stat-card {
    padding: 16px 18px;
  }

  .stat-value {
    font-size: 25px;
  }

  .member-row {
    grid-template-columns: minmax(0, 1fr);
    gap: 10px;
    padding: 14px 2px;
  }

  .member-tags {
    grid-column: 1 / -1;
  }

  .member-last {
    grid-column: 1 / -1;
  }

  .member-actions {
    grid-column: 1 / -1;
    grid-row: auto;
    flex-direction: row;
    justify-content: flex-start;
  }

  .msg-actions {
    align-self: flex-start;
  }

  .msg-head {
    flex-wrap: wrap;
  }

  .recent-time {
    margin-left: 0;
  }
}

@media (max-width: 680px) {
  .strategy-grid {
    grid-template-columns: minmax(0, 1fr);
    gap: 14px;
  }

  .strategy-card {
    padding: 17px 18px 15px;
  }

  .metric-value {
    font-size: 18px;
  }

  .history-item {
    grid-template-columns: minmax(0, 1fr);
    gap: 4px;
    padding: 11px 2px;
  }

  .history-tags {
    justify-content: flex-start;
  }

  .strategy-spark {
    align-items: center;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
