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

html, body {
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
}

[v-cloak] {
  display: none;
}

body {
  font-family: -apple-system, "PingFang SC", "Helvetica Neue", Arial, sans-serif;
  background: #f5f6fa;
  color: #1d2129;
  line-height: 1.5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ========== 全局滚动条美化 ========== */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: #c9cdd4;
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
  background: #a8adb8;
}
* {
  scrollbar-width: thin;
  scrollbar-color: #c9cdd4 transparent;
}

/* ========== 顶部导航 ========== */
.header {
  background: #3e63ef;
  color: #fff;
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 8px;
}

.header-logo {
  font-size: 18px;
  font-weight: 600;
}

.header-version {
  font-size: 10px;
  color: rgba(255,255,255,0.5);
  background: rgba(255,255,255,0.12);
  padding: 1px 6px;
  border-radius: 3px;
}

.header-time {
  font-size: 12px;
  color: rgba(255,255,255,0.7);
}

.header-user {
  position: relative;
  display: flex;
  align-items: center;
  cursor: pointer;
}
.user-avatar-header {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid rgba(255,255,255,0.2);
  transition: border-color 0.2s;
}
.user-avatar-header:hover {
  border-color: rgba(255,255,255,0.5);
}

/* 悬浮提示 */
.user-tooltip {
  display: none;
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 0;
  padding: 8px 14px;
  padding-top: 10px;
  min-width: 80px;
  z-index: 200;
  white-space: nowrap;
  text-align: center;
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.1);
  pointer-events: auto;
}
/* 鼠标从头像移到提示框的过渡桥 */
.header-user::before {
  content: '';
  position: absolute;
  top: 100%;
  right: 0;
  width: 80px;
  height: 10px;
  pointer-events: auto;
}
.header-user:hover .user-tooltip {
  display: block;
}
.tooltip-nick {
  font-size: 13px;
  color: #1d2129;
  font-weight: 600;
  padding-bottom: 6px;
  border-bottom: 1px solid #f0f0f0;
  margin-bottom: 6px;
}
.tooltip-logout {
  font-size: 12px;
  color: #86909c;
  cursor: pointer;
  transition: color 0.15s;
}
.tooltip-logout:hover {
  color: #e74c3c;
}

.header-refresh {
  background: rgba(255,255,255,0.12);
  border: none;
  color: #fff;
  width: 32px;
  height: 32px;
  border-radius: 6px;
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}

.header-refresh:hover {
  background: rgba(255,255,255,0.2);
}

.header-btn {
  position: relative;
  background: transparent;
  border: none;
  color: #fff;
  width: 34px;
  height: 34px;
  border-radius: 6px;
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
  line-height: 1;
}
.header-btn:hover { background: rgba(255,255,255,0.12); }
.header-btn[title]:hover::after {
  content: attr(title);
  position: absolute;
  top: 100%;
  margin-top: 4px;
  background: rgba(0,0,0,0.7);
  color: #fff;
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 4px;
  white-space: nowrap;
  pointer-events: none;
}

.logout-btn {
  background: rgba(255,255,255,0.12);
  border: 1px solid rgba(255,255,255,0.15);
  color: #fff;
  width: 34px;
  height: 34px;
  border-radius: 6px;
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
  flex-shrink: 0;
}
.logout-btn:hover { background: rgba(255,255,255,0.22); }

.header-btn-light {
  background: #f0f1f5;
  border: 1px solid transparent;
  color: #4e5969;
}
.header-btn-light:hover {
  background: #e5e6eb;
}

.header-refresh:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

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

.spinning {
  display: inline-block;
  animation: spin 1s linear infinite;
}

/* ========== 容器 ========== */
.container {
  max-width: 800px;
  margin: 0 auto;
  padding: 16px 12px 32px;
}

/* 大屏自适应布局 */
@media (min-width: 1200px) {
  .container { max-width: 1100px; }
  .index-grid { grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); }
}
@media (min-width: 1600px) {
  .container { max-width: 1400px; }
}
@media (min-width: 1900px) {
  .container { max-width: 1600px; }
  .index-grid { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); }
}

/* 宽屏多列布局：1500px 以上卡片两列排列 */
@media (min-width: 1500px) {
  .container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    align-items: start;
  }
  .container .summary-card,
  .container .chart-card {
    grid-column: 1 / -1;
  }
  .container .card {
    margin-bottom: 0;
  }
}

/* ========== 卡片通用 ========== */
.card {
  background: #fff;
  border-radius: 8px;
  padding: 20px;
  margin-bottom: 12px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
}

.section-title {
  font-size: 15px;
  font-weight: 600;
  color: #1d2129;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.section-count {
  font-size: 12px;
  color: #86909c;
  font-weight: 400;
}

.close-btn {
  background: #f2f3f5;
  border: none;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  font-size: 16px;
  cursor: pointer;
  color: #4e5969;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  font-weight: 500;
}

.close-btn:hover {
  background: #e74c3c;
  color: #fff;
}

/* ========== 持仓总览 ========== */
.summary-title {
  font-size: 13px;
  font-weight: 500;
  color: #86909c;
  margin-bottom: 14px;
}

.eye-btn {
  cursor: pointer;
  font-size: 18px;
  opacity: 0.4;
  transition: opacity 0.15s;
  margin-left: 6px;
  user-select: none;
  vertical-align: middle;
  line-height: 1;
  display: inline-block;
}

.eye-btn:hover {
  opacity: 0.8;
}

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

.summary-item {
  text-align: center;
  overflow: visible;
}

.summary-label {
  font-size: 12px;
  color: #86909c;
  margin-bottom: 2px;
}

.summary-value {
  display: inline-block;
  position: relative;
  font-size: 22px;
  font-weight: 700;
  color: #1d2129;
}

.summary-percent {
  position: absolute;
  left: 100%;
  top: 50%;
  transform: translateY(-50%);
  white-space: nowrap;
  font-size: 12px;
  font-weight: 400;
  margin-left: 4px;
}

/* ========== 收益颜色 ========== */
.income-up { color: #e74c3c !important; }
.income-down { color: #27ae60 !important; }
.income-flat { color: #86909c !important; }

/* ========== 账户列表 ========== */
.account-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.account-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: #f7f8fa;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s;
}

.account-item:hover {
  background: #f0f1f5;
}

.acc-eye {
  font-size: 14px;
  cursor: pointer;
  margin-left: 8px;
  opacity: 0.4;
  transition: opacity 0.15s;
  user-select: none;
  flex-shrink: 0;
}
.acc-eye:hover {
  opacity: 0.8;
}

.account-name {
  font-size: 14px;
  font-weight: 500;
  color: #1d2129;
}

.account-funds {
  font-size: 12px;
  color: #86909c;
}

.acc-status {
  font-size: 10px;
  padding: 0 6px;
  border-radius: 3px;
  line-height: 1.6;
  display: inline-block;
  font-weight: 500;
}
.status-all { color: #27ae60; background: #e8f8ef; }
.status-partial { color: #e67e22; background: #fef5e7; }
.status-pending { color: #95a5a6; background: #f0f1f5; }

/* 基金持仓中的更新状态 */
.fund-status {
  font-size: 10px;
  margin-left: 6px;
  padding: 0 5px;
  border-radius: 3px;
  font-weight: 500;
  vertical-align: middle;
}
.fund-done { color: #27ae60; background: #e8f8ef; }
.fund-pending { color: #95a5a6; background: #f0f1f5; }

.account-right {
  text-align: right;
  margin-left: auto;
}

.account-income {
  font-size: 15px;
  font-weight: 600;
}

.account-percent {
  font-size: 12px;
  margin-top: 1px;
}

/* ========== 大盘指数 ========== */
.index-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 8px;
}

.index-item {
  padding: 12px 8px;
  background: #f7f8fa;
  border-radius: 6px;
  text-align: center;
}

.index-name {
  font-size: 12px;
  color: #86909c;
  margin-bottom: 4px;
}

.index-value {
  font-size: 18px;
  font-weight: 600;
  color: #1d2129;
  margin-bottom: 2px;
}

.index-change {
  font-size: 12px;
  font-weight: 500;
}

.change-up { color: #e74c3c; }
.change-down { color: #27ae60; }

/* ========== 基金持仓 ========== */
.hold-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.hold-item {
  background: #f7f8fa;
  border-radius: 6px;
  padding: 14px 16px;
}

.hold-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
  padding-bottom: 10px;
  border-bottom: 1px solid #e5e6eb;
}

.hold-name {
  font-size: 14px;
  font-weight: 500;
  color: #1d2129;
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.hold-code {
  font-size: 11px;
  color: #86909c;
  background: #e5e6eb;
  padding: 2px 6px;
  border-radius: 3px;
  flex-shrink: 0;
}

.hold-body {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.hold-cell {
  text-align: center;
}

.hold-label {
  display: block;
  font-size: 11px;
  color: #86909c;
  margin-bottom: 2px;
}

.hold-value {
  font-size: 14px;
  font-weight: 600;
}

/* ========== 时间范围选择 ========== */
.range-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.range-btn {
  background: #f2f3f5;
  border: 1px solid transparent;
  padding: 4px 12px;
  border-radius: 4px;
  font-size: 12px;
  color: #4e5969;
  cursor: pointer;
  transition: all 0.15s;
}

.range-btn:hover {
  background: #e5e6eb;
}

.range-btn.active {
  background: #3e63ef;
  color: #fff;
  border-color: #3e63ef;
}

.date-extra {
  opacity: 0.55;
  margin-right: 2px;
}

.range-date-inputs {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.range-date {
  border: 1px solid #e5e6eb;
  border-radius: 4px;
  padding: 3px 8px;
  font-size: 12px;
  color: #4e5969;
  background: #fff;
  outline: none;
}

.range-date:focus {
  border-color: #3e63ef;
}

.range-date-sep {
  font-size: 12px;
  color: #86909c;
}

/* ========== 图表 ========== */
.chart-wrapper {
  position: relative;
  height: 260px;
}

.mode-group {
  display: inline-flex;
  gap: 0;
}

.mode-opt {
  background: #f2f3f5;
  border: 1px solid transparent;
  padding: 4px 12px;
  font-size: 12px;
  color: #4e5969;
  cursor: pointer;
  transition: all 0.15s;
  user-select: none;
}

.mode-opt:first-child {
  border-radius: 4px 0 0 4px;
}

.mode-opt:last-child {
  border-radius: 0 4px 4px 0;
  border-left: none;
}

.mode-opt:hover {
  background: #e5e6eb;
}

.mode-opt.active {
  background: #3e63ef;
  color: #fff;
  border-color: #3e63ef;
}

/* ========== 骨架屏加载 ========== */
.skeleton {
  max-width: 800px;
  margin: 0 auto;
  padding: 16px 12px;
}

.skeleton-header {
  height: 52px;
  background: linear-gradient(90deg, #e8ebf3 25%, #f0f2f8 50%, #e8ebf3 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: 8px;
  margin-bottom: 16px;
}

.skeleton-card {
  background: #fff;
  border-radius: 8px;
  padding: 20px;
  margin-bottom: 12px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.06);
}

.skeleton-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-top: 14px;
}

.skeleton-line {
  height: 14px;
  background: linear-gradient(90deg, #e8ebf3 25%, #f0f2f8 50%, #e8ebf3 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: 4px;
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ========== 空状态 ========== */
.empty-state {
  text-align: center;
  padding: 32px 16px;
  color: #86909c;
  font-size: 14px;
}

/* ========== 持仓模态框 ========== */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.45);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.capturing .modal-overlay {
  pointer-events: none;
}
.capturing .modal-overlay * {
  pointer-events: auto;
}

.modal {
  background: #fff;
  border-radius: 12px;
  max-width: 92vw;
  width: 92%;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 12px 48px rgba(0,0,0,0.2);
  font-size: 15px;
}

@media (min-width: 1200px) {
  .modal { max-width: 85vw; }
}

/* 模态框打开时禁止 body 滚动，用 padding 补偿滚动条宽度 */
body.modal-open {
  overflow: hidden;
  padding-right: 15px;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 24px;
  border-bottom: 1px solid #e5e6eb;
  flex-shrink: 0;
}

.modal-title {
  font-size: 18px;
  font-weight: 600;
  color: #1d2129;
}

.modal-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.modal-hint {
  font-size: 11px;
  color: #86909c;
}

.col-eye {
  font-size: 15px;
  cursor: pointer;
  margin-left: 4px;
  opacity: 0.4;
  transition: opacity 0.15s;
  user-select: none;
  vertical-align: middle;
  line-height: 1;
}
.col-eye:hover {
  opacity: 0.8;
}

.modal-body {
  padding: 0;
  overflow-y: auto;
  flex: 1;
  scroll-behavior: smooth;
}

.container {
  scroll-behavior: smooth;
}

.modal-body-inner {
  min-height: 0;
}

/* ========== 排序表格 ========== */
.sort-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.sort-table thead {
  position: sticky;
  top: 0;
  z-index: 1;
}

.sort-table th {
  background: #f7f8fa;
  padding: 14px 18px;
  text-align: left;
  font-weight: 600;
  color: #4e5969;
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
  border-bottom: 1px solid #e5e6eb;
  font-size: 14px;
}

.sort-table th:hover {
  background: #f0f1f5;
}

.sort-table .th-drag,
.sort-table .td-drag {
  width: 32px;
  text-align: center;
  cursor: grab;
}

.sort-table .th-code,
.sort-table .td-code {
  color: #86909c;
  font-size: 11px;
}

.sort-table .th-num,
.sort-table .td-num {
  text-align: right;
}

.sort-table .col-resize {
  position: relative;
}

.sort-table .resizer {
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  width: 5px;
  cursor: col-resize;
  z-index: 1;
}

.sort-table .resizer:hover,
.sort-table .resizer:active {
  background: rgba(62, 99, 239, 0.2);
}

.sort-table .th-name {
  min-width: 100px;
}

.sort-table .th-code,
.sort-table .td-code {
  color: #86909c;
  font-size: 12px;
}

.sort-table .th-sector,
.sort-table .td-sector {
  width: 6em;
  max-width: 6em;
  min-width: 6em;
  font-size: 13px;
  color: #4e5969;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* 截断文字悬浮效果：背景高亮 + 下划线提示可 hover */
.td-name:hover, .td-sector:hover, .td-code:hover {
  background: #eef0f5 !important;
  cursor: default;
}
.td-name:hover {
  text-decoration: underline;
  text-decoration-color: #c9cdd4;
  text-underline-offset: 2px;
}

.sort-table .th-num,
.sort-table .td-num {
  text-align: right;
  font-size: 15px;
  font-weight: 600;
}

.sort-arrow {
  font-size: 10px;
  margin-left: 2px;
  color: #3e63ef;
}

.drag-handle {
  font-size: 16px;
  color: #c9cdd4;
  line-height: 1;
}

.sort-table tbody tr {
  transition: background 0.1s;
}

.sort-table tbody tr:active {
  cursor: grabbing;
}

.sort-table tbody tr:hover {
  background: #f7f8fa;
}

.sort-table tbody tr.dragging {
  opacity: 0.4;
}

.sort-table tbody tr.drag-disabled {
  cursor: default;
}

.sort-table tbody tr.drag-over {
  border-top: 2px solid #3e63ef;
}

.sort-table td {
  padding: 14px 18px;
  border-bottom: 1px solid #f2f3f5;
  vertical-align: middle;
}

.th-spark, .td-spark {
  width: 80px;
  text-align: center;
  padding: 4px 8px !important;
}

.spark-canvas {
  width: 80px;
  height: 32px;
  cursor: pointer;
  border-radius: 2px;
  display: inline-block;
  vertical-align: middle;
}

.spark-canvas:hover {
  background: #f0f1f5;
}

.modal-lg {
  max-width: 800px;
}

.fund-chart-stats {
  display: flex;
  gap: 24px;
  margin-bottom: 16px;
  padding-bottom: 16px;
  border-bottom: 1px solid #e5e6eb;
}

.fc-stat {
  display: flex;
  align-items: baseline;
  gap: 6px;
  flex-wrap: wrap;
}

.fc-label {
  font-size: 12px;
  color: #86909c;
}

.fc-value {
  font-size: 18px;
  font-weight: 700;
}

.fc-rate {
  font-size: 12px;
  font-weight: 500;
}

.th-name, .td-name {
  width: 1%;
  white-space: nowrap;
  font-weight: 500;
  color: #1d2129;
  font-size: 15px;
}

/* ========== 截图功能（元素吸附） ========== */
.capture-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.12);
  z-index: 9995;
  pointer-events: none;
}

/* 截图模式下让 modal-overlay 不遮挡事件，仅 modal 本身可交互 */
.capture-mode .modal-overlay {
  pointer-events: none;
}
.capture-mode .modal-overlay > .modal {
  pointer-events: auto;
}

.capture-highlight {
  position: fixed;
  border: 2px solid #3e63ef;
  background: rgba(62,99,239,0.04);
  pointer-events: none;
  z-index: 9998;
  border-radius: 4px;
}

.capture-tip {
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  background: #1d2129;
  color: #fff;
  font-size: 13px;
  padding: 8px 20px;
  border-radius: 6px;
  z-index: 9999;
  white-space: nowrap;
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
  pointer-events: none;
}

.capture-esc {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0,0,0,0.5);
  color: #fff;
  font-size: 12px;
  padding: 6px 16px;
  border-radius: 4px;
  z-index: 9999;
  cursor: pointer;
}

.capture-esc:hover {
  background: rgba(0,0,0,0.7);
}

.capture-btn {
  background: #3e63ef;
  color: #fff;
  border: none;
  padding: 8px 20px;
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.15s;
}

.capture-btn:hover {
  background: #2b4fd9;
}

.modal-sm {
  max-width: 500px;
  width: auto;
  height: auto;
  max-height: 85vh;
}

/* ========== 加载状态 ========== */
.loading-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 60vh;
}

.loading-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid #e5e6eb;
  border-top-color: #3e63ef;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.loading-text {
  margin-top: 12px;
  color: #86909c;
  font-size: 14px;
}

/* ========== 错误提示 ========== */
.error-toast {
  position: fixed;
  top: 60px;
  left: 50%;
  transform: translateX(-50%);
  background: #fff;
  color: #e74c3c;
  padding: 10px 18px;
  border-radius: 6px;
  font-size: 13px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  border: 1px solid #ffe0e0;
  z-index: 200;
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: 90%;
}

.error-close {
  background: none;
  border: none;
  color: #e74c3c;
  cursor: pointer;
  font-size: 14px;
  padding: 2px;
  opacity: 0.5;
}

.error-close:hover { opacity: 1; }

/* ========== 响应式 ========== */
@media (max-width: 640px) {
  .header { padding: 12px 16px; }
  .container { padding: 12px 10px 24px; }
  .card { padding: 16px; }
  .summary-value { font-size: 18px; }
  .index-grid { grid-template-columns: repeat(3, 1fr); }
  .hold-body { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 400px) {
  .index-grid { grid-template-columns: repeat(2, 1fr); }
}
