/* ============================================================
 * FundBoard · base.css
 * 设计系统：令牌 / 布局 / 基础控件 / 表格 / 图表容器 / 提示
 * 约定：涨为红、跌为绿（国内基金习惯），类名 is-up / is-down
 * ============================================================ */

/* ---------- 设计令牌 ---------- */
:root {
  --fb-accent: #4f6ef7;
  --fb-accent-soft: #eef1ff;
  --fb-accent-deep: #3b55d9;
  --fb-up: #e34d59;
  --fb-down: #12a06f;
  --fb-flat: #8b97a9;

  --fb-bg: #f4f6fb;
  --fb-surface: #ffffff;
  --fb-surface-2: #fafbfe;
  --fb-line: #e7ecf4;
  --fb-line-strong: #d8e0ed;

  --fb-text: #1c2536;
  --fb-text-2: #5a6577;
  --fb-text-3: #8b97a9;

  --fb-radius: 14px;
  --fb-radius-sm: 9px;
  --fb-shadow: 0 1px 2px rgba(28, 37, 54, .04), 0 8px 24px -12px rgba(28, 37, 54, .12);
  --fb-shadow-lg: 0 18px 48px -20px rgba(28, 37, 54, .28);

  --fb-font: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei",
             "PingFang SC", "Hiragino Sans GB", Roboto, Helvetica, Arial, sans-serif;
  --fb-mono: "SF Mono", "JetBrains Mono", Consolas, "Courier New", monospace;

  --fb-max: 1220px;
}

/* ---------- 基础重置 ---------- */
*, *::before, *::after { box-sizing: border-box; }

/* hidden 属性在 flex/grid 元素上会被作者样式覆盖，这里强制生效 */
[hidden] { display: none !important; }

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

body {
  margin: 0;
  font-family: var(--fb-font);
  font-size: 14px;
  line-height: 1.6;
  color: var(--fb-text);
  background: var(--fb-bg);
  background-image:
    radial-gradient(900px 420px at 12% -10%, rgba(79, 110, 247, .09), transparent 62%),
    radial-gradient(760px 380px at 92% 0%, rgba(24, 169, 122, .07), transparent 60%);
  background-repeat: no-repeat;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--fb-accent); text-decoration: none; }
a:hover { color: var(--fb-accent-deep); }

h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -.01em; }
p { margin: 0; }
button { font-family: inherit; }
input { font-family: inherit; }

::selection { background: rgba(79, 110, 247, .18); }

/* ---------- 导航栏 ---------- */
.fb-nav {
  position: sticky;
  top: 0;
  z-index: 40;
  background: rgba(255, 255, 255, .82);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--fb-line);
}
.fb-nav-inner {
  max-width: var(--fb-max);
  margin: 0 auto;
  padding: 0 22px;
  height: 58px;
  display: flex;
  align-items: center;
  gap: 22px;
}
.fb-brand {
  display: flex;
  align-items: center;
  gap: 9px;
  font-weight: 700;
  font-size: 15px;
  color: var(--fb-text);
  letter-spacing: -.02em;
  white-space: nowrap;
}
.fb-brand:hover { color: var(--fb-text); }
.fb-brand-mark {
  width: 26px; height: 26px;
  border-radius: 8px;
  background: linear-gradient(135deg, #5a7bff, #7a5cf0 60%, #b45cf0);
  display: grid; place-items: center;
  color: #fff; font-size: 13px; font-weight: 700;
  box-shadow: 0 4px 12px -4px rgba(79, 110, 247, .7);
}
.fb-nav-links { display: flex; align-items: center; gap: 4px; margin-left: auto; }
.fb-nav-link {
  padding: 7px 13px;
  border-radius: 999px;
  font-size: 13px;
  color: var(--fb-text-2);
  transition: background .16s, color .16s;
  white-space: nowrap;
}
.fb-nav-link:hover { background: #eef1f8; color: var(--fb-text); }
.fb-nav-link.is-active { background: var(--fb-accent-soft); color: var(--fb-accent-deep); font-weight: 600; }

/* ---------- 布局 ---------- */
.fb-main {
  max-width: var(--fb-max);
  margin: 0 auto;
  padding: 26px 22px 72px;
}
.fb-page-head { margin-bottom: 22px; }
/* 页头小标签：三个页面统一用这一个 */
.fb-eyebrow {
  display: inline-block;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .05em;
  color: var(--fb-accent-deep);
  background: var(--fb-accent-soft);
  padding: 4px 11px;
  border-radius: 999px;
  margin-bottom: 10px;
}
.fb-page-title {
  font-size: 23px;
  font-weight: 700;
  letter-spacing: -.02em;
  display: flex; align-items: center; gap: 10px;
}
.fb-page-desc {
  margin-top: 7px;
  color: var(--fb-text-2);
  font-size: 13.5px;
  max-width: 760px;
}
.fb-page-desc b { color: var(--fb-text); font-weight: 650; }
.fb-page-desc code {
  font-family: var(--fb-mono);
  background: #eef1f8;
  padding: 1px 6px;
  border-radius: 5px;
  font-size: 12.5px;
  color: var(--fb-accent-deep);
}

.fb-grid { display: grid; gap: 18px; }
.fb-grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.fb-stack { display: flex; flex-direction: column; gap: 18px; }
.fb-spacer { flex: 1 1 auto; }

/* ---------- 卡片 ---------- */
.fb-card {
  background: var(--fb-surface);
  border: 1px solid var(--fb-line);
  border-radius: var(--fb-radius);
  box-shadow: var(--fb-shadow);
  padding: 18px 20px;
  min-width: 0;
}
.fb-card-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.fb-card-title {
  font-size: 15px;
  font-weight: 650;
  display: flex;
  align-items: center;
  gap: 8px;
}
.fb-card-title::before {
  content: '';
  width: 3px; height: 14px;
  border-radius: 2px;
  background: linear-gradient(180deg, var(--fb-accent), #8b5cf6);
}
.fb-card-note {
  font-size: 12px;
  color: var(--fb-text-3);
  line-height: 1.5;
}
.fb-card-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }
/* 卡片头中间的说明文字（放动态元信息，如区间、口径），两页统一 */
.fb-card-head > .fb-card-note { flex: 1 1 300px; min-width: 0; }
/* 图表 / 表格下方的静态解释 */
.fb-chart-note { margin-top: 10px; }

/* ---------- 控制区（两个对比页共用同一套结构） ---------- */
.fb-controls-top {
  display: flex;
  align-items: flex-end;
  gap: 14px;
  flex-wrap: wrap;
}
.fb-controls-picker { flex: 1 1 340px; min-width: 240px; }
.fb-controls-principal { flex: none; width: 152px; }
.fb-controls-money {
  width: 100%;
  text-align: right;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
}
.fb-controls-quick { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.fb-controls-quick .fb-btn {
  font-variant-numeric: tabular-nums;
  color: var(--fb-text-2);
}
.fb-controls-quick .fb-btn.is-active {
  border-color: #b7c3f8;
  background: var(--fb-accent-soft);
  color: var(--fb-accent-deep);
  font-weight: 650;
}

.fb-controls-chips {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 14px;
}
.fb-controls-chips > .fb-field-label { flex: none; white-space: nowrap; }
.fb-controls-chips .fb-chips { flex: 1 1 auto; }
.fb-chips-hint {
  display: inline-flex;
  align-items: center;
  height: 32px;
}

.fb-controls-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px dashed var(--fb-line);
}
.fb-controls-bar .fb-tabs { max-width: 100%; }

/* ---------- 口径说明列表（两页共用） ---------- */
.fb-notes-list {
  margin: 0;
  padding-left: 18px;
  display: flex;
  flex-direction: column;
  gap: 7px;
  font-size: 12.5px;
  line-height: 1.75;
  color: var(--fb-text-2);
}
.fb-notes-list b { color: var(--fb-text); font-weight: 650; }
.fb-notes-list code {
  font-family: var(--fb-mono);
  background: #f1f4f9;
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 11.5px;
  color: var(--fb-accent-deep);
}

/* ---------- 输入与按钮 ---------- */
.fb-input {
  height: 38px;
  padding: 0 12px;
  border: 1px solid var(--fb-line-strong);
  border-radius: var(--fb-radius-sm);
  background: var(--fb-surface);
  color: var(--fb-text);
  font-size: 13.5px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
  min-width: 0;
}
.fb-input::placeholder { color: #a8b2c2; }
.fb-input:focus {
  border-color: #b7c3f8;
  box-shadow: 0 0 0 3px rgba(79, 110, 247, .12);
}
.fb-input-lg { height: 44px; font-size: 14.5px; }

.fb-btn {
  height: 38px;
  padding: 0 15px;
  border: 1px solid var(--fb-line-strong);
  border-radius: var(--fb-radius-sm);
  background: var(--fb-surface);
  color: var(--fb-text-2);
  font-size: 13.5px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all .15s;
  white-space: nowrap;
}
.fb-btn:hover { border-color: #c3ccdd; color: var(--fb-text); background: var(--fb-surface-2); }
.fb-btn:active { transform: translateY(.5px); }
.fb-btn-ghost { border-color: transparent; background: transparent; }
.fb-btn-ghost:hover { background: #eef1f8; border-color: transparent; }
.fb-btn-sm { height: 30px; padding: 0 10px; font-size: 12.5px; }
.fb-btn[disabled] { opacity: .5; cursor: not-allowed; }

.fb-field { display: flex; flex-direction: column; gap: 6px; }
.fb-field-label { font-size: 12px; color: var(--fb-text-3); font-weight: 500; }

/* ---------- 区间切换 ---------- */
.fb-tabs {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 3px;
  background: #eef1f8;
  border-radius: 10px;
  flex-wrap: wrap;
}
.fb-tab {
  height: 30px;
  padding: 0 13px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--fb-text-2);
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  transition: all .15s;
  white-space: nowrap;
}
.fb-tab:hover { color: var(--fb-text); }
.fb-tab.is-active {
  background: var(--fb-surface);
  color: var(--fb-accent-deep);
  font-weight: 650;
  box-shadow: 0 1px 3px rgba(28, 37, 54, .1);
}

/* ---------- 基金胶囊 ---------- */
.fb-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.fb-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 32px;
  padding: 0 8px 0 11px;
  background: var(--fb-surface);
  border: 1px solid var(--fb-line-strong);
  border-radius: 999px;
  font-size: 12.5px;
  color: var(--fb-text);
  animation: fb-chip-in .2s ease-out;
}
@keyframes fb-chip-in { from { opacity: 0; transform: scale(.94); } to { opacity: 1; transform: none; } }
.fb-chip b { font-weight: 600; }
.fb-chip-dot { width: 8px; height: 8px; border-radius: 3px; flex: none; }
.fb-chip-code { color: var(--fb-text-3); font-family: var(--fb-mono); font-size: 11.5px; }
.fb-chip-x {
  width: 18px; height: 18px;
  border: 0; border-radius: 50%;
  background: transparent;
  color: var(--fb-text-3);
  cursor: pointer;
  font-size: 15px;
  line-height: 1;
  display: grid; place-items: center;
  transition: all .15s;
}
.fb-chip-x:hover { background: #ffe9ea; color: var(--fb-up); }

/* ---------- 搜索选择器 ---------- */
.fb-picker { position: relative; flex: 1 1 260px; min-width: 200px; }
.fb-picker-box {
  position: absolute;
  top: calc(100% + 6px);
  left: 0; right: 0;
  z-index: 50;
  background: var(--fb-surface);
  border: 1px solid var(--fb-line-strong);
  border-radius: 12px;
  box-shadow: var(--fb-shadow-lg);
  padding: 5px;
  max-height: 340px;
  overflow: auto;
  display: none;
}
.fb-picker-box.is-open { display: block; animation: fb-pop .14s ease-out; }
@keyframes fb-pop { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
.fb-picker-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  border-radius: 8px;
  cursor: pointer;
}
.fb-picker-item:hover, .fb-picker-item.is-active { background: var(--fb-accent-soft); }
.fb-picker-main { display: flex; align-items: baseline; gap: 8px; min-width: 0; flex: 1; }
.fb-picker-code { font-family: var(--fb-mono); font-size: 11.5px; color: var(--fb-text-3); flex: none; }
.fb-picker-name { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fb-picker-meta { display: flex; align-items: center; gap: 6px; flex: none; }
.fb-picker-type { font-size: 11px; color: var(--fb-text-3); white-space: nowrap; }
.fb-picker-empty, .fb-picker-loading {
  padding: 12px;
  text-align: center;
  color: var(--fb-text-3);
  font-size: 12.5px;
}
.fb-tag {
  font-size: 10.5px;
  padding: 1px 6px;
  border-radius: 5px;
  font-weight: 600;
  line-height: 1.5;
}
.fb-tag-money { background: #e8f7f1; color: var(--fb-down); }

/* ---------- 图表容器 ---------- */
.fb-chart { width: 100%; height: 320px; }
.fb-chart-tall { height: 380px; }

/* ---------- 指标卡 ---------- */
.fb-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.fb-stat {
  padding: 13px 15px;
  border-radius: 12px;
  background: var(--fb-surface-2);
  border: 1px solid var(--fb-line);
  min-width: 0;
}
.fb-stat-label { font-size: 12px; color: var(--fb-text-3); margin-bottom: 5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fb-stat-value {
  font-size: 21px;
  font-weight: 700;
  letter-spacing: -.02em;
  font-variant-numeric: tabular-nums;
  line-height: 1.25;
}
.fb-stat-sub { font-size: 11.5px; color: var(--fb-text-3); margin-top: 3px; }
.fb-stat.is-up .fb-stat-value { color: var(--fb-up); }
.fb-stat.is-down .fb-stat-value { color: var(--fb-down); }

/* ---------- 表格 ---------- */
.fb-table-wrap { overflow-x: auto; margin: 0 -4px; }
.fb-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}
.fb-table th {
  text-align: left;
  font-weight: 550;
  font-size: 12px;
  color: var(--fb-text-3);
  padding: 9px 10px;
  border-bottom: 1px solid var(--fb-line);
  white-space: nowrap;
  background: var(--fb-surface);
  position: sticky;
  top: 0;
}
.fb-table td {
  padding: 10px;
  border-bottom: 1px solid #f1f4f9;
  vertical-align: middle;
}
.fb-table tbody tr:last-child td { border-bottom: 0; }
.fb-table tbody tr { transition: background .12s; }
.fb-table tbody tr:hover { background: var(--fb-surface-2); }
.fb-table tr.is-selected { background: var(--fb-accent-soft); }
.fb-cell-name { font-weight: 600; display: flex; align-items: center; gap: 7px; }
.fb-cell-code { font-family: var(--fb-mono); font-size: 11px; color: var(--fb-text-3); font-weight: 400; }
.fb-cell-sub { font-size: 11px; color: var(--fb-text-3); margin-top: 1px; }

.ta-left { text-align: left; }
.ta-right { text-align: right; }
.ta-center { text-align: center; }

/* ---------- 涨跌配色 ---------- */
.is-up { color: var(--fb-up); }
.is-down { color: var(--fb-down); }
.is-flat { color: var(--fb-text-3); }

/* ---------- 提示 ---------- */
.fb-note {
  display: flex;
  gap: 8px;
  padding: 10px 13px;
  border-radius: 10px;
  background: #fff9ec;
  border: 1px solid #f6e3b8;
  color: #8a5d00;
  font-size: 12.5px;
  line-height: 1.55;
}
.fb-note-info { background: var(--fb-accent-soft); border-color: #d6defb; color: #3b4b8f; }
.fb-note b { font-weight: 650; }

.fb-toasts {
  position: fixed;
  left: 50%;
  bottom: 34px;
  transform: translateX(-50%);
  z-index: 999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  pointer-events: none;
}
.fb-toast {
  padding: 9px 16px;
  border-radius: 10px;
  background: rgba(28, 37, 54, .92);
  color: #fff;
  font-size: 13px;
  box-shadow: var(--fb-shadow-lg);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity .22s, transform .22s;
  max-width: 88vw;
}
.fb-toast.is-in { opacity: 1; transform: none; }
.fb-toast.is-error { background: rgba(199, 45, 58, .95); }

/* ---------- 加载 / 空态 ---------- */
.fb-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 44px 16px;
  color: var(--fb-text-3);
  font-size: 13px;
}
.fb-spinner {
  width: 15px; height: 15px;
  border: 2px solid var(--fb-line-strong);
  border-top-color: var(--fb-accent);
  border-radius: 50%;
  animation: fb-spin .7s linear infinite;
  flex: none;
}
@keyframes fb-spin { to { transform: rotate(360deg); } }

.fb-empty {
  padding: 40px 16px;
  text-align: center;
  color: var(--fb-text-3);
  font-size: 13px;
}

/* ---------- 通用小件 ---------- */
.fb-muted { color: var(--fb-text-3); }
.fb-small { font-size: 12px; }
.fb-mono { font-family: var(--fb-mono); }
.fb-legend-dot {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 2px;
  margin-right: 5px;
  vertical-align: 1px;
}
.fb-divider { height: 1px; background: var(--fb-line); margin: 14px 0; border: 0; }

/* ---------- 响应式 ---------- */
@media (max-width: 900px) {
  .fb-grid-2 { grid-template-columns: 1fr; }
  .fb-main { padding: 20px 14px 60px; }
  .fb-nav-inner { padding: 0 14px; gap: 12px; }
  .fb-nav-link { padding: 6px 10px; }
  .fb-page-title { font-size: 20px; }
  .fb-card { padding: 15px 14px; }
  .fb-stat-value { font-size: 18px; }
  .fb-chart { height: 260px; }
  .fb-controls-picker { flex: 1 1 100%; }
  .fb-controls-principal { width: 136px; }
}
@media (max-width: 560px) {
  .fb-nav-links .fb-nav-link span { display: none; }
  .fb-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .fb-controls-top { gap: 10px; }
  .fb-controls-principal { flex: 1 1 100%; width: auto; }
  .fb-controls-quick { width: 100%; }
  .fb-controls-quick .fb-btn { flex: 1 1 0; justify-content: center; }
  .fb-controls-chips { align-items: flex-start; }
  .fb-controls-chips > .fb-field-label { width: 100%; }
  .fb-controls-chips .fb-chips { flex-basis: 100%; }
  .fb-controls-bar .fb-tabs { width: 100%; }
  .fb-controls-bar .fb-tab { flex: 1 1 auto; text-align: center; }
  .fb-controls-bar .fb-spacer { display: none; }
}
