/* 基金费率计算器 - 样式 */

/* ── 色彩系统 ── */
:root {
  --bg-base: #0c1117;
  --bg-raised: #151d28;
  --bg-surface: #1c2636;
  --bg-input: #111922;
  --bg-elevated: #111827;
  --bg-subtle: #0f172a;
  --bg-hover: #1f2937;
  --bg-muted: #111827;
  --border: #253044;
  --border-hover: #3a4d6a;
  --border-focus: #4e8ce6;
  --border-subtle: #1f2937;

  --text-primary: #e8edf4;
  --text-secondary: #94a3b8;
  --text-tertiary: #64748b;
  --text-muted: #6b7280;
  --text-inverse: #0c1117;

  --accent: #4e8ce6;
  --accent-hover: #6aa1f0;
  --accent-subtle: rgba(78, 140, 230, 0.12);
  --accent-glow: rgba(78, 140, 230, 0.25);

  --green: #34d399;
  --green-subtle: rgba(52, 211, 153, 0.12);
  --yellow: #fbbf24;
  --yellow-subtle: rgba(251, 191, 36, 0.12);
  --red: #f87171;
  --red-subtle: rgba(248, 113, 113, 0.10);
  --pink: #f472b6;
  --purple: #a78bfa;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;

  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3), 0 1px 2px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.3), 0 2px 4px rgba(0, 0, 0, 0.2);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.4);

  /* 兼容别名 */
  --success: var(--green);
  --warning: var(--yellow);
  --danger: var(--red);

  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC',
    'Microsoft YaHei', sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace;

  --transition-fast: 0.15s ease;
  --transition-normal: 0.25s ease;
}

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

::selection {
  background: var(--accent-glow);
  color: var(--text-primary);
}

body {
  font-family: var(--font-body);
  background: var(--bg-base);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.6;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ── 布局 ── */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem 2rem 3rem;
}

/* ── 页头 ── */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 0.5rem;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid var(--border);
}

h1 {
  font-size: 1.65rem;
  font-weight: 700;
  margin-bottom: 0.4rem;
  background: linear-gradient(135deg, var(--text-primary) 40%, var(--accent) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -0.02em;
}

.subtitle {
  color: var(--text-secondary);
  font-size: 0.85rem;
  line-height: 1.5;
}

.page-header-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.15rem;
}

.page-header-link {
  font-size: 1rem;
  font-weight: 600;
  background: linear-gradient(135deg, var(--text-primary) 40%, var(--accent) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -0.02em;
  text-decoration: none;
}

.page-header-link:hover {
  text-decoration: underline;
}

.page-header .btn-secondary {
  flex-shrink: 0;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-secondary);
}

.page-header .btn-secondary:hover {
  border-color: var(--red);
  color: var(--red);
  background: var(--red-subtle);
}

/* ── 卡片区上方操作栏 ── */
.actions-above-cards {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 1rem;
  margin-top: 1.25rem;
}

.actions-above-cards-center {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.fund-search-wrap {
  position: relative;
  flex: 1;
  min-width: 200px;
  max-width: 320px;
}

.fund-search-input {
  width: 100%;
  padding: 0.5rem 0.75rem;
  font-size: 0.9rem;
  font-family: var(--font-body);
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  transition: border-color var(--transition-fast);
}

.fund-search-input::placeholder {
  color: var(--text-tertiary);
}

.fund-search-input:focus {
  outline: none;
  border-color: var(--border-focus);
}

.fund-search-dropdown {
  position: absolute;
  left: 0;
  right: 0;
  top: 100%;
  margin-top: 2px;
  max-height: 280px;
  overflow-y: auto;
  list-style: none;
  padding: 0.25rem 0;
  margin: 0;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
  z-index: 20;
  display: none;
}

.fund-search-dropdown.fund-search-dropdown-visible {
  display: block;
}

.fund-search-dropdown [role="option"] {
  padding: 0.4rem 0.75rem;
  font-size: 0.85rem;
  cursor: pointer;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.fund-search-dropdown [role="option"]:hover,
.fund-search-dropdown [role="option"].fund-search-item-active {
  background: var(--accent-subtle);
  color: var(--accent);
}

.fund-search-code {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--text-tertiary);
  flex-shrink: 0;
  width: 3.5rem;
}

.fund-search-name {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.fund-search-add-btn {
  margin-left: 0.5rem;
  padding: 0.1rem 0.4rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-secondary);
  font-size: 0.75rem;
  cursor: pointer;
}

.fund-search-add-btn.added {
  border-color: var(--accent);
  color: var(--accent);
}

.actions-above-cards-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-left: auto;
}

/* ── 缓存基金列表页面 ── */
.cached-funds-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
  margin-bottom: 1rem;
}

.cached-funds-search-wrap {
  position: relative;
  flex: 1 1 260px;
  min-width: 0;
}

.cached-funds-search-input {
  width: 100%;
  padding: 0.45rem 2rem 0.45rem 2rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  background: var(--bg-input);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.875rem;
  box-shadow: 0 0 0 1px rgba(15, 23, 42, 0.7);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast), background var(--transition-fast), transform var(--transition-fast);
}

.cached-funds-search-input::placeholder {
  color: var(--text-tertiary);
}

.cached-funds-search-wrap.focused .cached-funds-search-input {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 1px rgba(78, 140, 230, 0.7), 0 0 24px var(--accent-glow);
  background: radial-gradient(circle at top left, rgba(56, 189, 248, 0.18), rgba(15, 23, 42, 0.96));
  transform: translateY(-1px);
}

.cached-funds-search-icon {
  position: absolute;
  left: 0.65rem;
  top: 50%;
  transform: translateY(-50%);
  pointer-events: none;
}

.cached-funds-search-icon-img {
  width: 1.25rem;
  height: 1.25rem;
  border-radius: 999px;
  object-fit: cover;
  display: block;
}

.cached-funds-search-clear {
  position: absolute;
  right: 0.4rem;
  top: 50%;
  transform: translateY(-50%);
  width: 1.35rem;
  height: 1.35rem;
  border-radius: 999px;
  border: none;
  padding: 0;
  display: none;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  line-height: 1;
  background: transparent;
  color: var(--text-tertiary);
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast), transform var(--transition-fast);
}

.cached-funds-search-wrap.has-value .cached-funds-search-clear {
  display: inline-flex;
}

.cached-funds-search-clear:hover {
  background: rgba(15, 23, 42, 0.9);
  color: var(--text-primary);
  transform: translateY(-50%) scale(1.05);
}

.cached-funds-sort-select {
  flex: 0 0 auto;
  padding: 0.4rem 0.6rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-input);
  color: var(--text-primary);
  font-size: 0.85rem;
}

/* ── 筛选模块 ── */
.cf-filter-bar {
  margin-bottom: 0.75rem;
}

.cf-filter-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.3rem 0.7rem;
  font-family: inherit;
  font-size: 0.82rem;
  color: var(--text-secondary);
  cursor: pointer;
  transition: border-color var(--transition-fast), color var(--transition-fast);
}

.cf-filter-toggle:hover {
  border-color: var(--border-hover);
  color: var(--text-primary);
}

.cf-filter-toggle-icon {
  font-size: 0.65rem;
  transition: transform 0.2s ease;
}

.cf-filter-bar.cf-filter-open .cf-filter-toggle-icon {
  transform: rotate(90deg);
}

.cf-filter-active-count {
  font-size: 0.72rem;
  color: var(--accent);
  font-weight: 600;
}

.cf-filter-active-count:empty {
  display: none;
}

.cf-filter-panel {
  margin-top: 0.5rem;
  padding: 0.75rem 0.85rem;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  background: var(--bg-elevated);
}

.cf-filter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 0.65rem 1.25rem;
}

.cf-filter-group {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.cf-filter-label {
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--text-secondary);
}

.cf-filter-options {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
}

.cf-filter-options-scroll {
  max-height: 11rem;
  overflow-y: auto;
  padding-right: 0.15rem;
}

.cf-filter-tag {
  display: inline-flex;
  align-items: center;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-secondary);
  font-size: 0.75rem;
  font-family: inherit;
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
}

.cf-filter-tag:hover {
  border-color: var(--border-hover);
  color: var(--text-primary);
}

.cf-filter-tag.cf-filter-tag-active {
  background: var(--accent-subtle);
  border-color: var(--accent);
  color: var(--accent);
}

.cf-filter-range {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.cf-filter-input {
  width: 5.5rem;
  padding: 0.28rem 0.45rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-input);
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 0.8rem;
}

.cf-filter-input:focus {
  outline: none;
  border-color: var(--border-focus);
}

.cf-filter-input-wide {
  width: 100%;
  max-width: 16rem;
  font-family: inherit;
}

.cf-filter-range-sep {
  color: var(--text-tertiary);
  font-size: 0.8rem;
}

.cf-filter-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.65rem;
  padding-top: 0.5rem;
  border-top: 1px solid var(--border-subtle);
}

.cf-filter-result-hint {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-left: 0.5rem;
}

@media (max-width: 520px) {
  .cf-filter-grid {
    grid-template-columns: 1fr;
  }
}

.cached-funds-status {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

.cached-funds-status.error {
  color: var(--red);
}

.cached-funds-progress {
  position: relative;
  width: 100%;
  height: 4px;
  background: var(--bg-subtle);
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 0.5rem;
}

.cached-funds-progress-bar {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 0%;
  background: var(--accent);
  border-radius: inherit;
  transition: width 0.15s ease-out;
}

.cached-funds-table-wrap {
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  background: var(--bg-elevated);
  overflow: auto;
}

.cached-funds-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.cached-funds-table thead {
  background: var(--bg-muted);
}

.cached-funds-table th,
.cached-funds-table td {
  padding: 0.4rem 0.6rem;
  border-bottom: 1px solid var(--border-subtle);
  text-align: left;
  white-space: nowrap;
}

.cached-funds-table th {
  font-weight: 500;
  color: var(--text-secondary);
}

.cached-funds-table tbody tr:nth-child(odd) {
  background: var(--bg-subtle);
}

.cached-funds-table tbody tr:hover {
  background: var(--bg-hover);
}

.cached-funds-table tbody tr.cached-fund-row {
  cursor: pointer;
}

.cached-funds-table tbody tr.cached-fund-row-selected {
  background: color-mix(in srgb, var(--accent) 18%, var(--bg-subtle)) !important;
  box-shadow: inset 3px 0 0 0 var(--accent);
}

.cached-funds-table tbody tr.cached-fund-row-selected:hover {
  background: color-mix(in srgb, var(--accent) 24%, var(--bg-hover)) !important;
}

.cached-funds-compare-fab {
  position: fixed;
  right: max(12px, env(safe-area-inset-right));
  bottom: max(12px, env(safe-area-inset-bottom));
  z-index: 50;
}

.cached-funds-compare-fab[hidden] {
  display: none !important;
}

.cached-funds-compare-btn {
  padding: 12px 20px;
  font-size: 0.95rem;
  font-weight: 600;
  color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-strong, #4f46e5));
  border: none;
  border-radius: 999px;
  box-shadow: 0 8px 24px color-mix(in srgb, var(--accent) 45%, transparent);
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.cached-funds-compare-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 28px color-mix(in srgb, var(--accent) 55%, transparent);
}

.cached-funds-compare-btn:active {
  transform: translateY(0);
}

.cached-funds-empty {
  text-align: center;
  color: var(--text-muted);
}

.cached-funds-pagination {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  margin-top: 0.75rem;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.cached-funds-pagination-right {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.cached-funds-page-info {
  min-width: 4rem;
  text-align: center;
}

.cached-funds-page-size {
  padding: 0.25rem 0.5rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-input);
  color: var(--text-primary);
  font-size: 0.8rem;
}

/* ── 缓存基金统计页面 ── */
.fund-stats-summary {
  margin-bottom: 1.25rem;
  text-align: center;       /* 让「已缓存基金总数」整体居中 */
}

.fund-stats-summary-card {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.2rem;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-subtle);
  background: radial-gradient(circle at top left, rgba(56, 189, 248, 0.24), transparent 55%), var(--bg-elevated);
  box-shadow: var(--shadow-md);
}

.fund-stats-summary-number {
  font-size: 1.6rem;
  font-weight: 600;
  color: var(--accent);
}

.fund-stats-summary-label {
  font-size: 0.9rem;
  color: var(--text-primary);
}

.fund-stats-summary-sub {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.fund-stats-section {
  margin-top: 1.5rem;
}

.fund-stats-summary-extra {
  margin-left: 0.5rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.fund-stats-toggle {
  position: relative;
  display: flex;
  align-items: stretch;
  border-radius: 999px;
  padding: 2px;
  background: var(--bg-subtle);
  box-shadow: var(--shadow-sm);
  margin-bottom: 0.75rem;
  width: 100%;
  max-width: 100%;
}

.fund-stats-toggle-btn {
  position: relative;
  z-index: 1;
  border: none;
  background: transparent;
  padding: 0.4rem 1.1rem;
  font-size: 0.85rem;
  font-family: inherit;
  color: var(--text-muted);
  font-weight: 600;
  cursor: pointer;
  border-radius: 999px;
  transition: color 0.15s ease-out;
  flex: 1 1 0;
  text-align: center;
}

.fund-stats-toggle-btn-active {
  color: var(--text-primary);
}

.fund-stats-toggle-btn:hover {
  color: var(--text-primary);
}

.fund-stats-toggle-slider {
  position: absolute;
  top: 2px;
  bottom: 2px;
  left: 2px;
  width: calc((100% - 4px) / 4);
  border-radius: 999px;
  background: transparent;
  border: 1px solid var(--accent);
  box-shadow: 0 0 0 1px rgba(21, 94, 239, 0.4);
  transition: transform 0.2s ease-out;
}

.fund-stats-toggle-subtitle {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

.fund-stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 0.75rem;
}

@media (max-width: 520px) {
  .fund-stats-grid {
    grid-template-columns: 1fr;
  }
}

.fund-stats-card {
  position: relative;
  padding: 0.6rem 0.75rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  background: var(--bg-elevated);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  transition: transform 0.15s ease-out, box-shadow 0.15s ease-out, border-color 0.15s ease-out, background 0.15s ease-out;
}

.fund-stats-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at top right, rgba(56, 189, 248, 0.16), transparent 60%);
  opacity: 0;
  transition: opacity 0.2s ease-out;
}

.fund-stats-card:hover {
  transform: translateY(-2px) scale(1.01);
  box-shadow: var(--shadow-md);
  border-color: var(--border-hover);
  background: var(--bg-hover);
}

.fund-stats-card:hover::before {
  opacity: 1;
}

.fund-stats-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.35rem;
}

.fund-stats-card-title {
  font-size: 0.85rem;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.fund-stats-card-count {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--accent);
}

.fund-stats-card-bar-wrap {
  position: relative;
  width: 100%;
  height: 4px;
  border-radius: 999px;
  background: var(--bg-subtle);
  overflow: hidden;
  margin-bottom: 0.25rem;
}

.fund-stats-card-bar {
  position: absolute;
  inset: 0;
  width: 0%;
  background: linear-gradient(90deg, var(--accent), #3fb950);
  transform-origin: left;
  animation: fund-stats-bar-grow 0.4s ease-out forwards;
}

.fund-stats-card-meta {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.fund-stats-empty {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.fund-stats-grid-sentinel {
  width: 100%;
  height: 1px;
}

.fund-stats-fade-in {
  opacity: 0;
  transform: translateY(4px);
  animation: fund-stats-fade-in 0.25s ease-out forwards;
}

@keyframes fund-stats-fade-in {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fund-stats-bar-grow {
  from {
    width: 0%;
  }
}

.fund-stats-detail-section {
  margin-top: 0;
  max-height: none;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

#fund-stats-detail {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.fund-stats-detail-placeholder {
  border-radius: var(--radius-lg);
  border: 1px dashed var(--border-subtle);
  padding: 0.85rem 1rem;
  background: radial-gradient(circle at top left, rgba(56, 189, 248, 0.18), transparent 55%), var(--bg-surface);
  color: var(--text-secondary);
  font-size: 0.82rem;
}

.fund-stats-detail-placeholder-title {
  font-weight: 500;
  margin-bottom: 0.25rem;
}

.fund-stats-detail-placeholder-sub {
  font-size: 0.78rem;
  color: var(--text-tertiary);
}

.fund-stats-detail-card {
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-subtle);
  background: var(--bg-elevated);
  box-shadow: var(--shadow-md);
  padding: 0.9rem 1rem;
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: 1 1 auto;
}

.fund-stats-detail-loading {
  position: relative;
  overflow: hidden;
}

.fund-stats-detail-loading::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(148, 163, 184, 0.12), transparent);
  transform: translateX(-100%);
  animation: fund-stats-detail-shimmer 1.2s infinite;
}

@keyframes fund-stats-detail-shimmer {
  to {
    transform: translateX(100%);
  }
}

.fund-stats-detail-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.4rem;
}

.fund-stats-detail-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.fund-stats-detail-meta {
  font-size: 0.8rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.fund-stats-detail-header-main {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  min-width: 0;
}

.fund-stats-detail-close-btn {
  flex-shrink: 0;
  width: 1.75rem;
  height: 1.75rem;
  border-radius: 999px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-tertiary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1.1rem;
  transition: background var(--transition-fast), color var(--transition-fast), border-color var(--transition-fast), transform var(--transition-fast);
}

.fund-stats-detail-close-btn:hover {
  background: var(--red-subtle);
  border-color: var(--red);
  color: var(--red);
  transform: scale(1.03);
}

.fund-stats-detail-list {
  margin-top: 0.35rem;
  max-height: 100%;
  overflow: auto;
  padding-right: 0.25rem;
  flex: 1 1 auto;
  min-height: 0;
  scrollbar-gutter: stable;
  -webkit-overflow-scrolling: touch;
}

.fund-stats-detail-list::-webkit-scrollbar {
  width: 10px;
}

.fund-stats-detail-list::-webkit-scrollbar-track {
  background: var(--bg-base);
}

.fund-stats-detail-list::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 999px;
}

.fund-stats-detail-list::-webkit-scrollbar-thumb:hover {
  background: var(--border-hover);
}

.fund-stats-detail-list-skeleton {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.fund-stats-detail-row-skeleton {
  height: 1.9rem;
  border-radius: var(--radius-md);
  background: linear-gradient(90deg, var(--bg-subtle), #111827, var(--bg-subtle));
  background-size: 200% 100%;
  animation: fund-stats-detail-row-shimmer 1.4s ease-in-out infinite;
}

@keyframes fund-stats-detail-row-shimmer {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}

.fund-stats-detail-row {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  padding: 0.35rem 0.2rem;
  border-bottom: 1px solid rgba(37, 48, 68, 0.6);
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: background var(--transition-fast), box-shadow var(--transition-fast);
}

.fund-stats-detail-row:last-child {
  border-bottom: none;
}

.fund-stats-detail-row:hover {
  background: color-mix(in srgb, var(--accent) 10%, transparent);
}

.fund-stats-detail-row-selected {
  background: color-mix(in srgb, var(--accent) 18%, var(--bg-subtle));
  box-shadow: inset 2px 0 0 0 var(--accent);
}

.fund-stats-detail-order {
  flex-shrink: 0;
  width: 2.2rem;
  font-size: 0.78rem;
  font-family: var(--font-mono);
  color: var(--text-tertiary);
}

.fund-stats-detail-main {
  flex: 1;
  min-width: 0;
}

.fund-stats-detail-name-line {
  display: flex;
  align-items: baseline;
  gap: 0.45rem;
  margin-bottom: 0.15rem;
}

.fund-stats-detail-name {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.fund-stats-detail-code {
  font-size: 0.78rem;
  font-family: var(--font-mono);
  color: var(--text-tertiary);
}

.fund-stats-detail-extra {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
}

.fund-stats-detail-tag {
  display: inline-flex;
  align-items: center;
  padding: 0.05rem 0.45rem;
  border-radius: 999px;
  border: 1px solid rgba(37, 48, 68, 0.8);
  font-size: 0.7rem;
  color: var(--text-secondary);
  background: rgba(15, 23, 42, 0.9);
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.fund-stats-main {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  margin-top: 0.5rem;
}

.fund-stats-main-left {
  flex: 1 1 auto;
  min-width: 0;
  transition: flex-basis var(--transition-normal), max-width var(--transition-normal);
}

.fund-stats-main-right {
  position: relative;
  flex: 0 0 auto;
  min-width: 0;
  max-width: 0;
  opacity: 0;
  pointer-events: none;
  transform: translateX(8px);
  transition: max-width var(--transition-normal), opacity var(--transition-normal), transform var(--transition-normal);
}

.fund-stats-main.fund-stats-main-show-detail .fund-stats-main-left {
  flex: 0 0 62%;
  max-width: 62%;
}

.fund-stats-main.fund-stats-main-show-detail .fund-stats-main-right {
  max-width: 38%;
  opacity: 1;
  pointer-events: auto;
  transform: translateX(0);
}

@media (min-width: 900px) {
  .fund-stats-main-right {
    position: sticky;
    top: 0;
    height: 100vh;
    width: 100%;
    overflow: hidden;
  }

  .fund-stats-detail-section {
    height: 100%;
    overflow: hidden;
  }

  .fund-stats-detail-card {
    height: 100%;
    overflow: hidden;
  }
}

@media (max-width: 900px) {
  .fund-stats-main {
    flex-direction: column;
  }

  .fund-stats-main-left,
  .fund-stats-main.fund-stats-main-show-detail .fund-stats-main-left {
    flex: 1 1 auto;
    max-width: 100%;
  }

  .fund-stats-main-right {
    position: fixed;
    inset: 0;
    max-width: 100%;
    opacity: 0;
    pointer-events: none;
    transform: translateY(8px);
    background: var(--bg-base);
    z-index: 60;
    display: block;
    padding: 0;
    overflow: hidden;
  }

  .fund-stats-main.fund-stats-main-show-detail .fund-stats-main-right {
    max-width: 100%;
    width: 100%;
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
  }

  .fund-stats-detail-section {
    margin-top: 0;
    width: 100%;
    height: 100%;
    max-width: none;
    max-height: none;
    overflow: hidden;
  }

  .fund-stats-detail-card {
    height: 100%;
    border-radius: 0;
    overflow: hidden;
  }
}

/* ── 图表下方基金费率详情纵向表格 ── */
.fund-detail-table-wrap {
  margin-top: 1.25rem;
  margin-bottom: 1.75rem;
  overflow-x: auto;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  background: var(--bg-elevated);
}

.fund-detail-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}

.fund-detail-table th,
.fund-detail-table td {
  padding: 0.45rem 0.7rem;
  border-bottom: 1px solid var(--border-subtle);
  border-right: 1px solid var(--border-subtle);
  text-align: left;
  white-space: nowrap;
}

.fund-detail-table th:last-child,
.fund-detail-table td:last-child {
  border-right: none;
}

.fund-detail-table tr:last-child th,
.fund-detail-table tr:last-child td {
  border-bottom: none;
}

.fund-detail-table th.fund-detail-row-label {
  font-weight: 500;
  color: var(--text-secondary);
  background: var(--bg-muted);
  min-width: 7rem;
  white-space: nowrap;
  position: sticky;
  left: 0;
  z-index: 1;
}

.fund-detail-table td {
  color: var(--text-primary);
  min-width: 7rem;
}

.fund-detail-table td.fund-detail-fund-cell {
  cursor: pointer;
  transition: background var(--transition-fast), box-shadow var(--transition-fast);
}

.fund-detail-table td.fund-detail-fund-cell-selected {
  background: color-mix(in srgb, var(--accent) 20%, var(--bg-subtle)) !important;
  box-shadow: inset 0 -2px 0 0 var(--accent);
}

.fund-detail-table tr:first-child td {
  font-weight: 600;
}

.fund-detail-table tr:last-child td {
  padding-top: 0.35rem;
  padding-bottom: 0.45rem;
}

.fund-detail-color-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 0.4rem;
  vertical-align: middle;
  box-shadow: 0 0 5px currentColor;
}

.fund-detail-return-line {
  display: grid;
  grid-template-columns: 4.6em minmax(0, 1fr);
  align-items: baseline;
  column-gap: 0.45rem;
  padding: 0.08rem 0.28rem;
  border-radius: var(--radius-sm);
}

.fund-detail-return-best {
  background: var(--accent-subtle);
  color: var(--accent);
  font-weight: 600;
}

.fund-detail-return-period {
  color: var(--text-secondary);
  text-align: right;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.fund-detail-return-value {
  color: var(--text-primary);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.fund-detail-return-asof {
  margin-top: 0.18rem;
  opacity: 0.75;
}

/* ── 基金详情表操作行（排排网比较 / 选中 / 删除） ── */
.fund-detail-action-row th,
.fund-detail-action-row td {
  padding-top: 0.55rem;
  padding-bottom: 0.55rem;
  border-bottom: none;
}

.fund-detail-action-cell {
  white-space: nowrap;
}

.fund-detail-action-cell .btn + .btn {
  margin-left: 0.4rem;
}

.fund-detail-select-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  min-width: 3.6em;
  transition: all 0.15s ease;
}

.fund-detail-select-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(78, 140, 230, 0.08);
}

.fund-detail-select-btn.active {
  border-color: var(--accent);
  color: #fff;
  background: var(--accent);
}

.fund-detail-select-btn.active:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

.fund-detail-delete-btn {
  opacity: 0.6;
  transition: opacity 0.15s ease;
}

.fund-detail-delete-btn:hover {
  opacity: 1;
}

.fund-detail-compare-btn {
  white-space: nowrap;
}

.fund-detail-compare-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  box-shadow: none;
}

.fund-detail-no-mapping {
  display: inline-block;
  margin-left: 0.3rem;
  font-size: 0.68rem;
  color: var(--text-tertiary);
  opacity: 0.7;
}

.fund-detail-select-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.fund-detail-floating-actions {
  position: fixed;
  right: max(12px, env(safe-area-inset-right));
  bottom: max(12px, env(safe-area-inset-bottom));
  z-index: 65;
  display: flex;
  align-items: center;
  gap: 0.55rem;
}

.fund-detail-floating-actions[hidden] {
  display: none !important;
}

.fund-detail-floating-btn {
  padding: 0.55rem 0.95rem;
  border: 1px solid transparent;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform var(--transition-fast), box-shadow var(--transition-fast), opacity var(--transition-fast);
}

.fund-detail-floating-btn:hover {
  transform: translateY(-1px);
}

.fund-detail-floating-btn:active {
  transform: translateY(0);
}

.fund-detail-floating-compare {
  color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-hover));
  box-shadow: 0 8px 24px color-mix(in srgb, var(--accent) 40%, transparent);
}

.fund-detail-floating-delete {
  color: var(--text-primary);
  background: var(--bg-elevated);
  border-color: var(--border);
}

.fund-detail-floating-delete:hover {
  border-color: var(--red);
  color: var(--red);
  box-shadow: 0 8px 20px rgba(248, 113, 113, 0.18);
}

/* ── 基金卡片（单行横向排列，不需滚动时居中，多时可横向滚动）── */
.fund-cards {
  display: flex;
  flex-wrap: nowrap;
  gap: 1rem;
  margin-bottom: 1.75rem;
  margin-left: auto;
  margin-right: auto;
  width: max-content;
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  padding-bottom: 0.5rem;
  scroll-snap-type: x proximity;
  -webkit-overflow-scrolling: touch;
  scrollbar-gutter: stable;
}

.fund-cards::-webkit-scrollbar {
  height: 20px;
}

.fund-cards::-webkit-scrollbar-track {
  background: var(--bg-base);
  border-radius: 3px;
}

.fund-cards::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

.fund-cards::-webkit-scrollbar-thumb:hover {
  background: var(--border-hover);
}

.fund-card {
  flex: 0 0 auto;
  width: 360px;
  min-height: 0;
  scroll-snap-align: start;
  scroll-snap-stop: normal;
  position: relative;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem 1.25rem 1.25rem;
  transition: border-color var(--transition-normal), box-shadow var(--transition-normal);
}

.fund-card:hover {
  border-color: var(--border-hover);
  box-shadow: var(--shadow-md);
}

.fund-card h3 {
  font-size: 0.88rem;
  font-weight: 600;
  margin: 0 0 0.75rem 0;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.fund-card .color-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  box-shadow: 0 0 6px currentColor;
}

.fund-card .fund-name-label {
  color: var(--text-tertiary);
  font-size: 0.8rem;
  font-weight: 500;
}

.fund-card .fund-name-wrap {
  position: relative;
  flex: 1;
  min-width: 0;
}

.fund-card .fund-name {
  display: block;
  width: 30ch;
  min-width: 30ch;
  max-width: 100%;
  box-sizing: content-box;
  background: var(--bg-input);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.35rem 0.6rem;
  font-size: 0.85rem;
  font-family: var(--font-body);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.fund-card .fund-name-dropdown {
  position: absolute;
  left: 0;
  right: 0;
  top: 100%;
  margin-top: 2px;
  max-height: 220px;
  overflow-y: auto;
  list-style: none;
  padding: 0.25rem 0;
  margin: 0;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
  z-index: 25;
  display: none;
}

.fund-card .fund-name-dropdown.fund-name-dropdown-visible {
  display: block;
}

.fund-card .fund-name-dropdown [role="option"] {
  padding: 0.35rem 0.6rem;
  font-size: 0.82rem;
  cursor: pointer;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.fund-card .fund-name-dropdown [role="option"]:hover,
.fund-card .fund-name-dropdown [role="option"].fund-search-item-active {
  background: var(--accent-subtle);
  color: var(--accent);
}

.fund-card .fund-name:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--accent-subtle);
}

.fund-card .fund-name::placeholder {
  color: var(--text-tertiary);
}

.fund-card .fund-code {
  display: block;
  margin-top: 0.1rem;
  color: var(--text-tertiary);
  font-size: 0.8rem;
  font-variant-numeric: tabular-nums;
}

.fund-card .remove-btn {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.75rem;
  height: 1.75rem;
  padding: 0;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 50%;
  color: var(--text-tertiary);
  cursor: pointer;
  font-size: 1.1rem;
  line-height: 1;
  transition: all var(--transition-fast);
}

.fund-card .remove-btn:hover {
  background: var(--red-subtle);
  border-color: var(--red);
  color: var(--red);
}

/* ── 表单 ── */
.form-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.6rem;
}

.form-row label {
  min-width: 72px;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-secondary);
}

.fund-card .form-row {
  margin-bottom: 0.5rem;
}

.fund-card .form-row label {
  min-width: 64px;
}

.fund-card .segments-table {
  margin-top: 0.5rem;
}

.fund-card .segment-toolbar {
  margin-top: 0.45rem;
}

.form-row input {
  flex: 1;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  padding: 0.4rem 0.6rem;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.form-row input:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--accent-subtle);
}

.form-row input::placeholder {
  color: var(--text-tertiary);
  font-family: var(--font-body);
}

.fund-card .form-row-fee .input-buy-fee,
.fund-card .form-row-fee .input-annual-fee {
  width: 4rem;
  max-width: 5rem;
  min-width: 3rem;
  padding: 0.4rem 0.4rem;
  font-size: 0.8rem;
}

.fund-card .form-row-fee .input-unit {
  font-size: 0.9rem;
  color: var(--text-tertiary);
  margin-left: 0.2rem;
}

.fund-card .segment-section-label {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0.5rem 0 0.25rem 0;
  letter-spacing: 0.02em;
}

.form-hint {
  font-size: 0.72rem;
  color: var(--text-tertiary);
  line-height: 1.4;
}

/* 买入费率折扣区域样式 */
.calc-discount-wrap {
  display: inline-flex;
  flex-direction: row; /* 恢复水平排列，使 Label 和 Select 不换行 */
  align-items: center;
  gap: 0.35rem;
  margin-left: 0.5rem;
}

.calc-discount-label {
  font-size: 0.8rem;
  color: var(--text-tertiary);
  font-weight: 500;
  white-space: nowrap;
}

.calc-days-row {
  align-items: center;
  flex-wrap: wrap; /* 允许子元素换行 */
  row-gap: 0.75rem;
}

.calc-days-actions-right {
  margin-left: auto; /* 大屏时把 买入费率折扣 放到右侧 */
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.calc-days-row #calc-days-min,
.calc-days-row #calc-days-max {
  max-width: 90px;
}

.calc-days-sep {
  color: var(--text-tertiary);
  font-weight: 500;
  user-select: none;
}

/* 大号开关按钮：替代复选框，选中时背景高亮 */
.toggle-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.5rem 1.1rem;
  border-radius: var(--radius-md);
  font-family: var(--font-body);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--bg-surface);
  color: var(--text-primary);
  transition: all var(--transition-fast);
  user-select: none;
  white-space: nowrap;
  min-width: 0;
}

.toggle-btn:hover {
  border-color: var(--border-hover);
  background: var(--bg-raised);
}

.toggle-btn:has(.toggle-btn-input:checked) {
  background: var(--accent-subtle);
  border-color: var(--accent);
  color: var(--text-primary);
  box-shadow: 0 0 0 1px var(--accent), 0 0 14px var(--accent-glow);
}

.toggle-btn:has(.toggle-btn-input:checked):hover {
  background: rgba(78, 140, 230, 0.18);
  border-color: var(--accent-hover);
  box-shadow: 0 0 0 1px var(--accent-hover), 0 0 18px var(--accent-glow);
}

.toggle-btn-input {
  position: absolute;
  width: 0;
  height: 0;
  opacity: 0;
  margin: 0;
  pointer-events: none;
}

/* ── 分段费率表格 ── */
.segments-table {
  width: 100%;
  font-size: 0.8rem;
  margin-top: 0.75rem;
  border-collapse: separate;
  border-spacing: 0;
}

.segments-table th {
  color: var(--text-tertiary);
  font-weight: 600;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.5rem 0.5rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.segments-table td {
  padding: 0.35rem 0.5rem;
  text-align: left;
  border-bottom: 1px solid rgba(37, 48, 68, 0.5);
}

.segments-table tr:last-child td {
  border-bottom: none;
}

.segment-actions {
  width: 1%;
  white-space: nowrap;
}

.segment-del-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.5rem;
  height: 1.5rem;
  padding: 0;
  background: transparent;
  border: none;
  color: var(--text-tertiary);
  cursor: pointer;
  font-size: 1.1rem;
  line-height: 1;
  border-radius: var(--radius-sm);
  font-family: inherit;
  transition: all var(--transition-fast);
}

.segment-del-btn:hover {
  color: var(--red);
  background: var(--red-subtle);
}

.segment-toolbar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.6rem;
  flex-wrap: wrap;
}

.segment-quick {
  font-size: 0.75rem;
  color: var(--text-tertiary);
  margin-left: 0.25rem;
}

.segment-toolbar .btn-sm {
  padding: 0.25rem 0.5rem;
  font-size: 0.75rem;
}

.fund-card .unbounded-rate-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.5rem;
  padding: 0.4rem 0;
  border-top: 1px dashed var(--border);
}

.fund-card .unbounded-rate-label {
  font-size: 0.8rem;
  color: var(--text-secondary);
  white-space: nowrap;
}

.fund-card .input-unbounded-rate {
  width: 4rem;
  max-width: 80px;
  padding: 0.25rem 0.4rem;
  font-size: 0.8rem;
  font-family: var(--font-mono);
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
}

.fund-card .unbounded-rate-unit {
  font-size: 0.8rem;
  color: var(--text-tertiary);
}

.fund-card .unbounded-quick-btns {
  display: flex;
  gap: 0.25rem;
  flex-wrap: wrap;
}

.fund-card .unbounded-quick-btns .btn-sm {
  padding: 0.2rem 0.4rem;
  font-size: 0.7rem;
}

.segments-table .unbounded-days-cell,
.segments-table .unbounded-rate-cell {
  color: var(--text-secondary);
  font-size: 0.8rem;
}

.segments-table input {
  width: 100%;
  max-width: 80px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  padding: 0.25rem 0.4rem;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.segments-table input:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--accent-subtle);
}

/* ── 操作区 ── */
.actions {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 1.75rem;
  flex-wrap: wrap;
  align-items: center;
}

/* ── 按钮 ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.5rem 1.1rem;
  border-radius: var(--radius-md);
  font-family: var(--font-body);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--bg-surface);
  color: var(--text-primary);
  transition: all var(--transition-fast);
  user-select: none;
  white-space: nowrap;
}

.btn:hover {
  border-color: var(--border-hover);
  background: var(--bg-raised);
}

.btn:active {
  transform: scale(0.97);
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 600;
  box-shadow: 0 2px 8px rgba(78, 140, 230, 0.3);
}

.btn-primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  color: #fff;
  box-shadow: 0 4px 16px rgba(78, 140, 230, 0.35);
}

.btn-card {
  background: var(--bg-surface);
  border-color: var(--border);
  color: var(--text-primary);
  font-weight: 500;
}

.btn-card:hover {
  border-color: var(--border-hover);
  background: var(--bg-raised);
  color: var(--text-primary);
}

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

.btn-secondary:hover {
  border-color: var(--red);
  color: var(--red);
  background: var(--red-subtle);
}

.btn-sm {
  padding: 0.25rem 0.55rem;
  font-size: 0.78rem;
  border-radius: var(--radius-sm);
}

/* ── 图表容器 ── */
.chart-container {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  margin-bottom: 1rem;
  position: relative;
  min-height: 500px;
  height: calc(100vh - 14rem);
  box-shadow: var(--shadow-md);
  display: flex;
  flex-direction: column;
}

.chart-main {
  display: flex;
  align-items: stretch;
  gap: 0.75rem;
  flex: 1 1 auto;
  min-height: 0;
}

.chart-main-left {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.chart-main-right {
  flex: 0 0 340px;
  max-width: 380px;
  min-width: 220px;
  display: flex;
  flex-direction: row;
  border-left: 1px solid var(--border-subtle);
  transition: flex-basis 0.25s, min-width 0.25s, padding 0.25s;
}

.chart-fund-list-toggle {
  flex-shrink: 0;
  width: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  color: var(--text-tertiary);
  font-size: 1rem;
  cursor: pointer;
  padding: 0;
  transition: color 0.15s;
}
.chart-fund-list-toggle:hover { color: var(--text-primary); }
.chart-fund-list-toggle-arrow {
  line-height: 1;
  flex-shrink: 0;
}

.chart-fund-list-body {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding-left: 0.5rem;
  overflow: hidden;
}

/* 收起态 */
.chart-main-right.collapsed {
  flex: 0 0 36px;
  min-width: 36px;
  max-width: 36px;
  padding-left: 0;
}
.chart-main-right.collapsed .chart-fund-list-body {
  display: none;
}
.chart-main-right.collapsed .chart-fund-list-toggle {
  width: 100%;
  flex-direction: column;
  gap: 4px;
  padding: 6px 0;
  overflow-y: auto;
  align-items: center;
}
.chart-collapsed-dots {
  display: none;
}
.chart-main-right.collapsed .chart-collapsed-dots {
  display: contents;
}
.chart-collapsed-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  flex-shrink: 0;
  box-shadow: 0 0 4px currentColor;
  opacity: 0.35;
}
.chart-collapsed-dot.active {
  opacity: 1;
}

.chart-fund-list-header {
  font-size: 0.8rem;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex-wrap: wrap;
}

.chart-fund-list-hint {
  font-size: 0.75rem;
  color: var(--text-tertiary);
}

.chart-fund-list-show-all,
.chart-fund-list-hide-all {
  font-size: 0.75rem;
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.chart-fund-list-show-all {
  margin-left: auto;
}

.chart-fund-list-show-all-active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.chart-fund-list {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  max-height: 50vh;
  padding-right: 0.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.chart-fund-list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.4rem;
  padding: 0.25rem 0.35rem;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  font-size: 0.8rem;
}

.chart-fund-list-item-active {
  border-color: var(--accent);
  background: rgba(56, 189, 248, 0.07);
}

.chart-fund-list-item-left {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  min-width: 0;
}

.chart-fund-list-color {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  flex-shrink: 0;
  box-shadow: 0 0 6px currentColor;
}

.chart-fund-list-name {
  flex: 1 1 auto;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chart-fund-list-code {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-tertiary);
}

.chart-wrapper {
  position: relative;
  flex: 1 1 auto;
  min-height: 310px;
}

/* ── 十字线 ── */
.chart-crosshair-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 10;
}

.chart-crosshair-overlay .chart-crosshair-v,
.chart-crosshair-overlay .chart-crosshair-h,
.chart-crosshair-overlay .chart-crosshair-label-x,
.chart-crosshair-overlay .chart-crosshair-label-y,
.chart-crosshair-overlay .chart-crosshair-info {
  opacity: 0;
  transition: opacity 0.1s ease-out;
}

.chart-crosshair-overlay.visible .chart-crosshair-v,
.chart-crosshair-overlay.visible .chart-crosshair-h,
.chart-crosshair-overlay.visible .chart-crosshair-label-x,
.chart-crosshair-overlay.visible .chart-crosshair-label-y,
.chart-crosshair-overlay.visible .chart-crosshair-info {
  opacity: 1;
}

.chart-crosshair-v {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 1px;
  background: rgba(255, 255, 255, 0.35);
  transform: translateX(-50%);
  z-index: 1;
}

.chart-crosshair-h {
  position: absolute;
  left: 0;
  right: 0;
  height: 1px;
  background: rgba(255, 255, 255, 0.35);
  transform: translateY(-50%);
  z-index: 1;
}

.chart-crosshair-label-x {
  position: absolute;
  bottom: 4px;
  transform: translate(-50%, 0);
  font-size: 0.7rem;
  font-family: var(--font-mono);
  color: var(--text-primary);
  background: var(--bg-raised);
  padding: 0.15rem 0.5rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-hover);
  box-shadow: var(--shadow-sm);
  z-index: 10;
}

.chart-crosshair-label-y {
  position: absolute;
  left: 4px;
  transform: translate(0, -50%);
  font-size: 0.7rem;
  font-family: var(--font-mono);
  color: var(--text-primary);
  background: var(--bg-raised);
  padding: 0.15rem 0.5rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-hover);
  box-shadow: var(--shadow-sm);
  z-index: 10;
}

.chart-crosshair-info {
  position: absolute;
  top: 8px;
  font-size: 0.75rem;
  font-family: var(--font-mono);
  color: var(--text-primary);
  background: var(--bg-raised);
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-hover);
  line-height: 1.6;
  box-shadow: var(--shadow-md);
  backdrop-filter: blur(8px);
  z-index: 20;
}

/* 图表曲线悬停框（优先级最高） */
.chart-hover-tooltip {
  position: absolute;
  max-width: min(360px, calc(100% - 16px));
  font-size: 0.75rem;
  font-family: var(--font-mono);
  color: var(--text-primary);
  background: var(--bg-raised);
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-hover);
  box-shadow: var(--shadow-md);
  line-height: 1.55;
  backdrop-filter: blur(8px);
  pointer-events: none;
  opacity: 0;
  transform: translateY(2px);
  transition: opacity 0.08s ease-out, transform 0.08s ease-out;
  z-index: 30;
}

.chart-hover-tooltip.visible {
  opacity: 1;
  transform: translateY(0);
}

.chart-hover-tooltip-title {
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 0.25rem;
}

.chart-hover-tooltip-body {
  color: var(--text-secondary);
}

/* ── 底部色带 ── */
.optimal-band {
  margin-top: 0.75rem;
}

.optimal-band-strip {
  display: flex;
  height: 10px;
  border-radius: 5px;
  overflow: visible;
  box-shadow: var(--shadow-sm);
}

.optimal-band-segment {
  position: relative;
  flex-shrink: 0;
  min-width: 2px;
  cursor: pointer;
  transition: filter var(--transition-fast);
}

.optimal-band-segment:hover {
  filter: brightness(1.2);
}

.optimal-band-segment:first-child {
  border-radius: 5px 0 0 5px;
}

.optimal-band-segment:last-child {
  border-radius: 0 5px 5px 0;
}

.optimal-band-segment:only-child {
  border-radius: 5px;
}

.optimal-band-segment-tooltip {
  position: absolute;
  left: 50%;
  top: 100%;
  transform: translateX(-50%);
  margin-top: 8px;
  padding: 0.35rem 0.7rem;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-primary);
  background: var(--bg-raised);
  border: 1px solid var(--border-hover);
  border-radius: var(--radius-md);
  white-space: nowrap;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--transition-fast), visibility var(--transition-fast);
  pointer-events: none;
  z-index: 10;
}

.optimal-band-segment-tooltip::before {
  content: '';
  position: absolute;
  bottom: 100%;
  left: 50%;
  margin-left: -5px;
  border: 5px solid transparent;
  border-bottom-color: var(--border-hover);
}

.optimal-band-segment-tooltip.visible {
  opacity: 1;
  visibility: visible;
}

.optimal-band-labels {
  position: relative;
  height: 1.25rem;
  margin-top: 3px;
}

.optimal-band-boundary-label {
  position: absolute;
  transform: translateX(-50%);
  font-size: 0.68rem;
  font-family: var(--font-mono);
  color: var(--text-tertiary);
  white-space: nowrap;
}

/* ── 交叉点图例 / 全程最优 ── */
/* 色带下方两栏：左费用、右功能按钮 */
.chart-footer {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin-top: 1rem;
  align-items: flex-start;
}

.chart-footer-left {
  flex: 1;
  min-width: 0;
}

.chart-footer-right {
  flex-shrink: 0;
  display: flex;
  align-items: center;
}

.chart-footer .crossover-legend {
  margin-top: 0;
}

.crossover-legend {
  padding: 0.85rem 1rem;
  background: var(--bg-base);
  border-radius: var(--radius-md);
  font-size: 0.82rem;
  border: 1px solid rgba(37, 48, 68, 0.5);
}

.crossover-legend .optimal-single {
  margin: 0;
  color: var(--text-primary);
}

.crossover-legend .optimal-single strong {
  color: var(--green);
}

.crossover-legend h4 {
  margin: 0 0 0.5rem 0;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.crossover-legend ul {
  margin: 0;
  padding-left: 1.25rem;
}

.crossover-legend li {
  margin-bottom: 0.3rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

.crossover-legend li strong {
  color: var(--text-primary);
  font-family: var(--font-mono);
}

.crossover-legend .none {
  color: var(--text-tertiary);
}

.crossover-legend .penetration-legend-title {
  margin-top: 0.75rem;
  margin-bottom: 0.35rem;
}

.crossover-legend .penetration-legend-list {
  margin-bottom: 0;
}

/* 图表下方功能按钮（去除前7天、数据悬浮窗） */
.chart-options {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
}

/* ── 图表区域响应式调整（中等屏幕）── */
@media (max-width: 1024px) {
  .chart-container {
    height: auto;
    min-height: 460px;
  }

  .chart-main-right {
    flex: 0 0 300px;
    max-width: 320px;
  }

  .chart-footer {
    flex-direction: column;
    align-items: stretch;
  }

  .chart-footer-right {
    justify-content: flex-start;
  }
}

.toggle-btn.toggle-btn-inline {
  padding-inline: 0.6rem;
}

/** 联接基金穿透开关：ETF 联接不存在双重收费，功能保留但隐藏入口 */
.hide-penetrate-linked {
  display: none !important;
}

.toggle-select {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 0.8rem;
  padding: 0.2rem 0.5rem;
  margin-inline: 0.25rem;
  outline: none;
}

.toggle-select:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 2px var(--accent-subtle);
}

/* ── 弹窗（导入） ── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(5, 10, 20, 0.65);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
  backdrop-filter: blur(8px);
}

.modal-backdrop.modal-visible {
  display: flex;
}

.modal {
  width: min(780px, 100% - 2rem);
  max-height: calc(100vh - 4rem);
  background: var(--bg-surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-hover);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modal-confirm {
  width: min(720px, 100% - 2rem);
}

.modal-header {
  padding: 0.9rem 1.1rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.modal-header h2 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
}

.modal-close-btn {
  border: none;
  background: transparent;
  color: var(--text-tertiary);
  width: 1.75rem;
  height: 1.75rem;
  border-radius: 999px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  transition: background var(--transition-fast), color var(--transition-fast), transform var(--transition-fast);
}

.modal-close-btn:hover {
  color: var(--red);
  background: var(--red-subtle);
  transform: scale(1.05);
}

.modal-body {
  padding: 0.9rem 1.1rem 0.9rem;
  overflow: auto;
}

.modal-footer {
  padding: 0.75rem 1.1rem 0.85rem;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  background: var(--bg-base);
}

.modal-footer-left {
  flex: 1;
  min-width: 0;
}

.modal-footer-right {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* 仅在 allfund 原始数据弹窗中，将底部按钮居中 */
.modal-json .modal-footer {
  justify-content: center;
}

.modal-intro {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 0.75rem;
}

.modal-hint {
  font-size: 0.78rem;
  color: var(--text-tertiary);
}

.modal-label {
  display: block;
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-bottom: 0.25rem;
}

.modal-textarea {
  width: 100%;
  min-height: 150px;
  max-height: 260px;
  resize: vertical;
  background: var(--bg-input);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  padding: 0.6rem 0.75rem;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--text-primary);
  line-height: 1.5;
}

.modal-textarea::placeholder {
  color: var(--text-tertiary);
}

.modal-textarea:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--accent-subtle);
}

/* allfund 原始 JSON 弹窗样式 */
.modal-json {
  width: min(900px, 100% - 2rem);
}

.modal-json-pre {
  margin: 0;
  padding: 0.75rem 0.9rem;
  background: var(--bg-base);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--text-secondary);
  max-height: calc(100vh - 10rem);
  overflow: auto;
  white-space: pre;
}

.modal-json-table {
  margin-top: 0.5rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--bg-base);
  max-height: calc(100vh - 10rem);
  overflow: auto;
}

.modal-json-table-inner {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
}

.modal-json-table-inner-nested {
  margin: 0.25rem 0;
  font-size: 0.78rem;
  background: var(--bg-subtle);
}

.modal-json-table-inner th,
.modal-json-table-inner td {
  padding: 0.3rem 0.55rem;
  border-bottom: 1px solid var(--border-subtle);
  text-align: left;
  vertical-align: top;
}

.modal-json-table-inner th {
  width: 9rem;
  font-weight: 500;
  color: var(--text-secondary);
  font-family: var(--font-mono);
}

.modal-json-table-inner td {
  color: var(--text-primary);
  word-break: break-all;
}

.modal-json-table-empty {
  padding: 0.6rem 0.8rem;
  font-size: 0.8rem;
  color: var(--text-tertiary);
}

.modal-json-empty-object,
.modal-json-empty-array {
  font-family: var(--font-mono);
  color: var(--text-tertiary);
}

.modal-json-circular {
  font-family: var(--font-mono);
  color: var(--warning);
}

/* ── 指数选择弹窗 ── */
.modal-index-picker {
  width: 90vw;
  max-height: 90vh;
  height: calc(100vh - 2rem);
}

.modal-index-picker .modal-body {
  display: flex;
  gap: 0.9rem;
  align-items: stretch;
  flex: 1 1 auto;
  overflow: hidden;
}

.index-picker-top {
  flex: 0 0 40%;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.index-picker-bottom {
  flex: 0 0 60%;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  height: 100%;
}

.index-picker-search-row {
  margin-bottom: 0.75rem;
}

.index-picker-index-list {
  flex: 1 1 auto;
  max-height: none;
  overflow: auto;
  padding-right: 4px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  background: var(--bg-base);
}

.index-picker-index-item {
  padding: 0.4rem 0.6rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  cursor: pointer;
  border-bottom: 1px solid rgba(15, 23, 42, 0.65);
}

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

.index-picker-index-item:hover,
.index-picker-index-item.index-picker-index-item-active {
  background: var(--accent-subtle);
}

.index-picker-index-name {
  font-size: 0.86rem;
  font-weight: 500;
  color: var(--text-primary);
}

.index-picker-index-meta {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.index-picker-divider {
  display: none;
}

.index-picker-bottom-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.index-picker-bottom-title {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  min-width: 0;
}

.index-picker-selected-count {
  font-size: 0.78rem;
  color: var(--text-tertiary);
}

.index-picker-bottom-actions {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.index-picker-fund-list {
  flex: 1 1 auto;
  max-height: none;
  overflow: auto;
  padding-right: 4px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  background: var(--bg-base);
}

.index-picker-fund-item {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.4rem 0.6rem;
  border-bottom: 1px solid rgba(15, 23, 42, 0.65);
}

.index-picker-fund-item:last-child {
  border-bottom: none;
}

.index-picker-fund-main {
  display: flex;
  flex-direction: column;
  gap: 0.12rem;
  min-width: 0;
}

.index-picker-fund-name-line {
  display: flex;
  align-items: baseline;
  gap: 0.35rem;
}

.index-picker-fund-name {
  font-size: 0.86rem;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.index-picker-fund-code {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--text-tertiary);
}

.index-picker-fund-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
}

.index-picker-fund-tag {
  font-size: 0.7rem;
  color: var(--text-secondary);
  padding: 0.05rem 0.45rem;
  border-radius: 999px;
  border: 1px solid rgba(37, 48, 68, 0.9);
  background: rgba(15, 23, 42, 0.9);
}

.index-picker-fund-item-selected {
  background: rgba(30, 64, 175, 0.35);
}

.index-picker-fund-item-selected .index-picker-fund-name {
  color: var(--accent);
}

.index-picker-toggle-active {
  background: var(--accent-subtle);
  color: var(--accent);
  border-color: var(--accent);
}

/* ── 指数独立页面 ── */
.index-page {
  min-height: 100vh;
}

.index-page-search-hero {
  margin-top: 1rem;
  padding: 1.25rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: radial-gradient(circle at top left, rgba(56, 189, 248, 0.2), transparent 45%), var(--bg-surface);
}

.index-page-search-label {
  display: block;
  margin-bottom: 0.45rem;
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.index-page-search-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.index-page-search-wrap {
  max-width: none;
}

.index-page-search-input {
  font-size: 0.95rem;
  padding: 0.62rem 0.85rem;
}

.index-page-search-meta {
  margin-top: 0.5rem;
}

.index-page-selected-chips {
  margin-top: 0.65rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.index-page-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  border: 1px solid var(--border-hover);
  border-radius: 999px;
  padding: 0.18rem 0.25rem 0.18rem 0.55rem;
  font-size: 0.76rem;
  color: var(--text-primary);
  background: var(--bg-input);
  transition: border-color var(--transition-fast);
}

.index-page-chip:hover {
  border-color: var(--accent);
}

.index-page-chip em {
  font-style: normal;
  color: var(--accent);
}

.index-page-chip-remove {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.15rem;
  height: 1.15rem;
  border: none;
  border-radius: 999px;
  background: transparent;
  color: var(--text-tertiary);
  font-size: 0.85rem;
  line-height: 1;
  cursor: pointer;
  padding: 0;
  transition: background var(--transition-fast), color var(--transition-fast);
}

.index-page-chip-remove:hover {
  background: var(--red-subtle);
  color: var(--red);
}

.index-page-suggestions {
  margin-top: 0.5rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
}

.index-page-suggestions:empty {
  display: none;
}

.index-page-suggest-label {
  font-size: 0.72rem;
  color: var(--text-tertiary);
  white-space: nowrap;
}

.index-page-suggest-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  border: 1px dashed var(--border);
  border-radius: 999px;
  padding: 0.12rem 0.5rem;
  font-size: 0.72rem;
  font-family: inherit;
  color: var(--text-secondary);
  background: transparent;
  cursor: pointer;
  transition: border-color var(--transition-fast), color var(--transition-fast), background var(--transition-fast);
}

.index-page-suggest-chip:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-subtle);
}

.index-page-suggest-chip em {
  font-style: normal;
  font-size: 0.68rem;
  color: var(--text-tertiary);
}

.index-page-main {
  margin-top: 1rem;
}

.index-page-main-hidden {
  display: none;
}

.index-page-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.8rem;
}

.index-page-toolbar-left {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.index-page-toolbar-label {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.index-page-period-wrap {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  margin-left: 0.25rem;
}

.index-page-period-wrap-hidden {
  visibility: hidden;
}

.index-page-period-btn-active {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-subtle);
}

.index-page-summary {
  margin-bottom: 0.9rem;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.6rem;
}

.index-page-summary-card {
  width: 100%;
}

.index-page-content {
  display: grid;
  grid-template-columns: minmax(0, 58%) minmax(0, 42%);
  gap: 0.75rem;
}

.index-page-left,
.index-page-right {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  min-width: 0;
}

.index-page-panel {
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  background: var(--bg-elevated);
  box-shadow: var(--shadow-sm);
  padding: 0.75rem;
}

.index-page-panel-title {
  font-size: 0.88rem;
  margin-bottom: 0.5rem;
  color: var(--text-secondary);
}

.index-page-table-wrap {
  max-height: 520px;
}

.index-page-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--bg-muted);
}

.index-page-sort-col-active {
  color: var(--accent) !important;
}

.index-page-chart-wrap {
  height: 300px;
  position: relative;
}

@media (max-width: 980px) {
  .index-page-content {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .index-page-search-row {
    flex-direction: column;
    align-items: stretch;
  }

  .index-page-summary {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .modal-index-picker {
    width: min(100%, 100% - 1.5rem);
  }

  .modal-index-picker .modal-body {
    flex-direction: column;
  }

  .index-picker-bottom-actions {
    flex-wrap: wrap;
    justify-content: flex-end;
  }
}

.import-main {
  display: grid;
  grid-template-columns: 1.6fr 1.1fr;
  gap: 0.9rem;
  align-items: stretch;
}

.import-file-wrap {
  border-radius: var(--radius-md);
  border: 1px dashed var(--border);
  background: linear-gradient(135deg, rgba(37, 48, 68, 0.5), rgba(12, 17, 23, 0.9));
  padding: 0.8rem 0.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  transition: border-color var(--transition-fast), background var(--transition-fast), box-shadow var(--transition-fast), transform var(--transition-fast);
}

.import-file-wrap.import-file-dragover {
  border-color: var(--accent);
  background: radial-gradient(circle at top, rgba(78, 140, 230, 0.18), rgba(12, 17, 23, 0.95));
  box-shadow: 0 0 0 1px var(--accent), 0 0 24px var(--accent-glow);
  transform: translateY(-1px);
}

.import-file-inner {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.import-file-title {
  font-size: 0.86rem;
  font-weight: 500;
  color: var(--text-primary);
}

.import-file-subtitle {
  font-size: 0.78rem;
  color: var(--text-secondary);
}

.import-file-hint {
  font-size: 0.76rem;
  color: var(--text-tertiary);
  margin-top: 0.15rem;
}

.modal-file-input {
  display: none;
}

.import-file-select-btn {
  border-style: dashed;
  border-color: var(--border);
  background: transparent;
}

.import-file-select-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(78, 140, 230, 0.08);
}

.fund-import-result-list {
  max-height: 280px;
  overflow: auto;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--bg-surface);
}

.fund-import-result-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid rgba(37, 48, 68, 0.7);
}

.fund-import-result-item:last-child {
  border-bottom: none;
}

.fund-import-result-main {
  flex: 1;
  min-width: 0;
}

.fund-import-result-line1 {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.5rem;
  margin-bottom: 0.15rem;
}

.fund-import-result-name {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-primary);
}

.fund-import-result-code {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--text-tertiary);
}

.fund-import-result-source {
  font-size: 0.78rem;
  color: var(--text-tertiary);
  word-break: break-all;
}

.fund-import-result-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.1rem 0.45rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  font-size: 0.68rem;
  color: var(--text-secondary);
  background: rgba(15, 23, 42, 0.9);
}

.fund-import-result-actions {
  flex-shrink: 0;
}

.modal-empty-hint {
  font-size: 0.8rem;
  color: var(--text-tertiary);
  margin-top: 0.5rem;
}

@media (max-width: 720px) {
  .import-main {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 480px) {
  .modal {
    width: 100%;
    max-height: 100vh;
    border-radius: 0;
  }

  .modal-header,
  .modal-body,
  .modal-footer {
    padding-left: 0.8rem;
    padding-right: 0.8rem;
  }
}

/* ── 空状态 ── */
.empty-state {
  text-align: center;
  padding: 3rem 2rem;
  color: var(--text-tertiary);
}

.empty-state p {
  margin: 0.5rem 0;
}

/* ── 滚动条 ── */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--bg-base);
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--border-hover);
}

/* ── 响应式 ── */
@media (max-width: 640px) {
  body {
    overflow-x: hidden; /* 小屏禁止整页横向滚动，去掉右侧空白 */
  }

  .container {
    padding: 1rem;
  }

  h1 {
    font-size: 1.3rem;
  }

  .fund-cards {
    margin-bottom: 1.25rem;
    padding-bottom: 0.4rem;
  }

  .fund-card {
    width: 320px;
    padding: 1rem 1rem 1rem;
  }

  .chart-wrapper {
    min-height: 260px;
    flex: 1 1 auto;
  }

  .chart-container {
    min-height: 440px;
    height: auto;
    padding: 0.75rem;
  }

  .chart-main {
    flex-direction: column;
  }

  .chart-main-right {
    flex: 0 0 auto;
    max-width: none;
    min-width: 0;
    border-left: none;
    border-top: 1px solid var(--border-subtle);
    padding-left: 0;
    padding-top: 0.5rem;
    flex-direction: column;
  }
  .chart-main-right .chart-fund-list-toggle {
    display: none;
  }
  .chart-main-right .chart-fund-list-body {
    padding-left: 0;
  }

  .chart-fund-list {
    max-height: 220px;
  }

  .actions-above-cards {
    flex-direction: column;
    gap: 0.5rem;
    align-items: stretch;
  }

  .calc-days-actions-right {
    margin-left: 0;           /* 小屏取消右对齐 */
    width: 100%;              /* 占满一行，自动换到下方 */
    justify-content: flex-end;
  }
}
