/* FundIT Data - Morningstar Style */
:root {
  /* Morningstar 品牌色系 */
  --ms-blue: #003366;
  --ms-blue-light: #0056b3;
  --ms-orange: #f56300;
  --ms-orange-light: #ff7a1a;
  --ms-dark: #1a1a1a;
  --ms-text: #333333;
  --ms-text-secondary: #666666;
  --ms-text-muted: #999999;
  --ms-border: #e0e0e0;
  --ms-border-light: #f0f0f0;
  --ms-bg: #ffffff;
  --ms-bg-light: #f5f5f5;
  --ms-bg-hover: #fafafa;
  --ms-green: #1e7e34;
  --ms-red: #dc3545;
  --ms-yellow: #f5a623;
  
  /* 字体 */
  --font-primary: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: "SF Mono", Monaco, "Cascadia Code", "Roboto Mono", Consolas, monospace;
}

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

body {
  font-family: var(--font-primary);
  background: var(--ms-bg);
  color: var(--ms-text);
  line-height: 1.5;
  font-size: 14px;
}

/* ===== 顶部导航栏 ===== */
.ms-header {
  background: var(--ms-blue);
  border-bottom: 3px solid var(--ms-orange);
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 1000;
}

.ms-header-left {
  display: flex;
  align-items: center;
  gap: 32px;
  flex: 1;
}

/* Desktop Navigation */
.desktop-nav {
  display: flex;
  gap: 0;
}

/* Mobile Navigation (hidden by default) */
.mobile-nav {
  display: none !important;
}

.ms-logo {
  font-size: 24px;
  font-weight: 700;
  color: #fff;
  letter-spacing: -0.5px;
}

.ms-logo span {
  color: var(--ms-orange);
}

.ms-logo.active {
  background: rgba(255,255,255,0.15);
  border-radius: 4px;
  padding: 4px 8px;
  margin-left: -8px;
}

.ms-nav {
  display: flex;
  gap: 0;
}

.ms-nav-item {
  color: rgba(255,255,255,0.9);
  padding: 0 20px;
  height: 60px;
  display: flex;
  align-items: center;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  border-bottom: 3px solid transparent;
  margin-bottom: -3px;
}

.ms-nav-item:hover,
.ms-nav-item.active {
  color: #fff;
  background: rgba(255,255,255,0.1);
  border-bottom-color: var(--ms-orange);
}

.ms-header-center {
  display: flex;
  align-items: center;
  flex: 1;
  justify-content: center;
  padding: 0 16px;
}

.ms-header-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.ms-search-box {
  position: relative;
}

.ms-search-box input {
  width: 280px;
  height: 36px;
  padding: 0 36px 0 12px;
  border: 1px solid rgba(255,255,255,0.3);
  border-radius: 4px;
  background: rgba(255,255,255,0.1);
  color: #fff;
  font-size: 13px;
}

.ms-search-box input::placeholder {
  color: rgba(255,255,255,0.6);
}

.ms-search-box input:focus {
  outline: none;
  border-color: var(--ms-orange);
  background: #fff;
  color: var(--ms-text);
}

.ms-search-box input:focus::placeholder {
  color: var(--ms-text-muted);
}

/* 用户菜单 */
.ms-user-menu {
  position: relative;
}

.ms-user-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: 4px;
  cursor: pointer;
  color: #fff;
  font-size: 13px;
  transition: background 0.2s;
}

.ms-user-btn:hover {
  background: rgba(255,255,255,0.15);
}

.ms-user-avatar {
  width: 32px;
  height: 32px;
  background: var(--ms-orange);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 12px;
}

.ms-badge {
  padding: 3px 8px;
  border-radius: 3px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.ms-badge.qualified {
  background: var(--ms-green);
  color: #fff;
}

.ms-badge.retail {
  background: var(--ms-yellow);
  color: #fff;
}

/* 下拉菜单 */
.ms-dropdown {
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 8px;
  background: #fff;
  border: 1px solid var(--ms-border);
  border-radius: 4px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.15);
  min-width: 200px;
  display: none;
  z-index: 1001;
}

.ms-dropdown.show {
  display: block;
}

.ms-dropdown-item {
  padding: 12px 16px;
  cursor: pointer;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--ms-text);
}

.ms-dropdown-item:hover {
  background: var(--ms-bg-light);
}

.ms-dropdown-divider {
  height: 1px;
  background: var(--ms-border);
  margin: 4px 0;
}

.ms-dropdown-item.danger {
  color: var(--ms-red);
}

/* ===== 二级导航 ===== */
.ms-subnav {
  background: #fff;
  border-bottom: 1px solid var(--ms-border);
  padding: 0 24px;
  display: flex;
  gap: 0;
}

.ms-subnav-item {
  padding: 14px 20px;
  font-size: 13px;
  font-weight: 500;
  color: var(--ms-text-secondary);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 6px;
}

.ms-subnav-item:hover {
  color: var(--ms-blue);
}

.ms-subnav-item.active {
  color: var(--ms-blue);
  border-bottom-color: var(--ms-orange);
  font-weight: 600;
}

.ms-subnav-item.locked {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ===== 页面布局 ===== */
.ms-container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 24px;
}

.ms-page-header {
  margin-bottom: 24px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--ms-border);
}

.ms-page-title {
  font-size: 28px;
  font-weight: 700;
  color: var(--ms-dark);
  margin-bottom: 8px;
}

.ms-page-subtitle {
  font-size: 14px;
  color: var(--ms-text-secondary);
  max-width: 800px;
  line-height: 1.6;
}

/* ===== 面包屑 ===== */
.ms-breadcrumb {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
  font-size: 12px;
  color: var(--ms-text-muted);
}

.ms-breadcrumb a {
  color: var(--ms-blue-light);
  text-decoration: none;
}

.ms-breadcrumb a:hover {
  text-decoration: underline;
}

/* ===== 数据表格 ===== */
.ms-data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.ms-data-table thead th {
  background: var(--ms-bg-light);
  padding: 12px 16px;
  text-align: left;
  font-weight: 600;
  color: var(--ms-text);
  border-bottom: 2px solid var(--ms-border);
  white-space: nowrap;
}

.ms-data-table thead th.sortable {
  cursor: pointer;
}

.ms-data-table thead th.sortable:hover {
  background: var(--ms-border-light);
}

.ms-data-table tbody td {
  padding: 16px;
  border-bottom: 1px solid var(--ms-border-light);
  vertical-align: top;
}

.ms-data-table tbody tr {
  cursor: pointer;
  transition: background 0.15s;
}

.ms-data-table tbody tr:hover {
  background: var(--ms-bg-hover);
}

/* 基金名称列 */
.ms-fund-name {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.ms-fund-name .name {
  font-size: 14px;
  font-weight: 600;
  color: var(--ms-blue-light);
}

.ms-fund-name .name:hover {
  color: var(--ms-orange);
}

.ms-fund-name .ticker {
  font-size: 12px;
  color: var(--ms-text-muted);
  font-family: var(--font-mono);
}

.ms-fund-name .category {
  font-size: 11px;
  color: var(--ms-text-secondary);
}

/* 星级评分 */
.ms-rating {
  display: flex;
  gap: 2px;
}

.ms-star {
  color: var(--ms-orange);
  font-size: 14px;
}

.ms-star.empty {
  color: var(--ms-border);
}

/* 数值显示 */
.ms-value {
  font-family: var(--font-mono);
  font-weight: 500;
}

.ms-value.positive {
  color: var(--ms-green);
}

.ms-value.negative {
  color: var(--ms-red);
}

.ms-value.large {
  font-size: 15px;
  font-weight: 600;
}

/* 标签 */
.ms-tag {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 3px;
  font-size: 11px;
  font-weight: 500;
  background: var(--ms-bg-light);
  color: var(--ms-text-secondary);
  border: 1px solid var(--ms-border);
}

.ms-tag.primary {
  background: var(--ms-blue);
  color: #fff;
  border-color: var(--ms-blue);
}

.ms-tag.success {
  background: var(--ms-green);
  color: #fff;
  border-color: var(--ms-green);
}

.ms-tag.warning {
  background: var(--ms-yellow);
  color: #fff;
  border-color: var(--ms-yellow);
}

/* ===== 筛选栏 ===== */
.ms-filter-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  padding: 16px;
  background: var(--ms-bg-light);
  border-radius: 4px;
}

.ms-filter-left {
  display: flex;
  gap: 12px;
  align-items: center;
}

.ms-filter-right {
  display: flex;
  align-items: center;
}

.ms-record-count {
  font-size: 13px;
  color: var(--ms-text-secondary);
  font-weight: 500;
}

.ms-filter-select {
  padding: 8px 32px 8px 12px;
  border: 1px solid var(--ms-border);
  border-radius: 4px;
  background: #fff;
  font-size: 13px;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23666' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
}

.ms-filter-select:focus {
  outline: none;
  border-color: var(--ms-blue);
}

.ms-btn {
  padding: 8px 16px;
  border-radius: 4px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

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

.ms-btn-primary:hover {
  background: var(--ms-orange-light);
}

.ms-btn-secondary {
  background: #fff;
  color: var(--ms-text);
  border-color: var(--ms-border);
}

.ms-btn-secondary:hover {
  background: var(--ms-bg-light);
}

/* ===== 登录页面 ===== */
.ms-login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--ms-bg-light);
}

.ms-login-box {
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.08);
  width: 100%;
  max-width: 420px;
  padding: 40px;
}

.ms-login-header {
  text-align: center;
  margin-bottom: 32px;
}

.ms-login-header .logo {
  font-size: 32px;
  font-weight: 700;
  color: var(--ms-blue);
  margin-bottom: 8px;
}

.ms-login-header .logo span {
  color: var(--ms-orange);
}

.ms-login-header p {
  color: var(--ms-text-secondary);
  font-size: 14px;
}

.ms-form-group {
  margin-bottom: 20px;
}

.ms-form-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--ms-text);
  margin-bottom: 6px;
}

.ms-form-group input {
  width: 100%;
  padding: 12px 16px;
  border: 1px solid var(--ms-border);
  border-radius: 4px;
  font-size: 14px;
  transition: all 0.2s;
}

.ms-form-group input:focus {
  outline: none;
  border-color: var(--ms-blue);
  box-shadow: 0 0 0 3px rgba(0,51,102,0.08);
}

.ms-form-group textarea {
  width: 100%;
  padding: 12px 16px;
  border: 1px solid var(--ms-border);
  border-radius: 4px;
  font-size: 14px;
  transition: all 0.2s;
  resize: vertical;
  min-height: 80px;
  font-family: var(--font-primary);
}

.ms-form-group textarea:focus {
  outline: none;
  border-color: var(--ms-blue);
  box-shadow: 0 0 0 3px rgba(0,51,102,0.08);
}

.ms-form-row {
  display: flex;
  gap: 16px;
}

.ms-btn-block {
  width: 100%;
  padding: 14px;
  font-size: 14px;
  font-weight: 600;
}

.ms-login-footer {
  text-align: center;
  margin-top: 24px;
  padding-top: 24px;
  border-top: 1px solid var(--ms-border-light);
  font-size: 12px;
  color: var(--ms-text-muted);
}

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

.ms-modal {
  background: #fff;
  border-radius: 8px;
  width: 100%;
  max-width: 600px;
  max-height: 90vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 60px rgba(0,0,0,0.2);
}

.ms-modal-header {
  padding: 24px 24px 0;
}

.ms-modal-header h2 {
  font-size: 20px;
  font-weight: 700;
  color: var(--ms-dark);
}

.ms-modal-header p {
  color: var(--ms-text-secondary);
  font-size: 14px;
  margin-top: 4px;
}

.ms-modal-body {
  padding: 20px 24px;
  overflow-y: auto;
  flex: 1;
}

.ms-modal-footer {
  padding: 16px 24px 24px;
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  border-top: 1px solid var(--ms-border-light);
}

/* 问卷选项 */
.ms-question {
  margin-bottom: 24px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--ms-border-light);
}

.ms-question:last-child {
  border-bottom: none;
  margin-bottom: 0;
  padding-bottom: 0;
}

.ms-question h4 {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 12px;
  color: var(--ms-text);
}

.ms-options {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ms-option {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  border: 1px solid var(--ms-border);
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s;
  font-size: 13px;
}

.ms-option:hover {
  background: var(--ms-bg-light);
  border-color: var(--ms-blue);
}

.ms-option input {
  margin-right: 10px;
  width: 16px;
  height: 16px;
  accent-color: var(--ms-orange);
}

.ms-option.selected {
  border-color: var(--ms-orange);
  background: rgba(245, 99, 0, 0.05);
}

/* ===== 详情页 ===== */
.ms-detail-header {
  background: #fff;
  border-bottom: 1px solid var(--ms-border);
  padding: 24px;
  margin-bottom: 24px;
}

.ms-detail-title {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.ms-detail-title h1 {
  font-size: 24px;
  font-weight: 700;
  color: var(--ms-dark);
}

.ms-detail-meta {
  display: flex;
  gap: 24px;
  margin-top: 16px;
  flex-wrap: wrap;
}

.ms-meta-item {
  font-size: 13px;
  color: var(--ms-text-secondary);
}

.ms-meta-item strong {
  color: var(--ms-text);
  margin-left: 4px;
}

/* 指标卡片 */
.ms-metrics-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.ms-metric-card {
  background: #fff;
  border: 1px solid var(--ms-border);
  border-radius: 4px;
  padding: 20px;
  text-align: center;
}

.ms-metric-card .label {
  font-size: 12px;
  color: var(--ms-text-secondary);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.ms-metric-card .value {
  font-size: 24px;
  font-weight: 700;
  color: var(--ms-dark);
  font-family: var(--font-mono);
}

.ms-metric-card .change {
  font-size: 12px;
  margin-top: 4px;
}

/* 图表容器 */
.ms-chart-container {
  background: #fff;
  border: 1px solid var(--ms-border);
  border-radius: 4px;
  padding: 24px;
  margin-bottom: 24px;
}

.ms-chart-container h3 {
  font-size: 16px;
  font-weight: 700;
  color: var(--ms-dark);
  margin-bottom: 20px;
}

.ms-chart-placeholder {
  height: 300px;
  background: var(--ms-bg-light);
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ms-text-muted);
}

/* ===== 空状态 ===== */
.ms-empty {
  text-align: center;
  padding: 80px 20px;
  color: var(--ms-text-secondary);
}

.ms-empty-icon {
  font-size: 48px;
  margin-bottom: 16px;
  opacity: 0.5;
}

.ms-empty h3 {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--ms-text);
}

/* ===== 锁定提示 ===== */
.ms-lock-notice {
  background: #fff;
  border: 1px solid var(--ms-border);
  border-radius: 4px;
  padding: 60px 40px;
  text-align: center;
}

.ms-lock-notice-icon {
  font-size: 48px;
  margin-bottom: 16px;
}

.ms-lock-notice h3 {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 8px;
  color: var(--ms-dark);
}

.ms-lock-notice p {
  color: var(--ms-text-secondary);
  max-width: 400px;
  margin: 0 auto;
  font-size: 14px;
  line-height: 1.6;
}

/* ===== 组合列表 ===== */
.ms-portfolio-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.ms-portfolio-card {
  background: #fff;
  border: 1px solid var(--ms-border);
  border-radius: 4px;
  padding: 20px;
  cursor: pointer;
  transition: all 0.2s;
}

.ms-portfolio-card:hover {
  border-color: var(--ms-blue);
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

.ms-portfolio-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 12px;
}

.ms-portfolio-name {
  font-size: 16px;
  font-weight: 700;
  color: var(--ms-blue-light);
}

.ms-portfolio-name:hover {
  color: var(--ms-orange);
}

.ms-portfolio-value {
  font-size: 20px;
  font-weight: 700;
  color: var(--ms-dark);
  font-family: var(--font-mono);
}

.ms-portfolio-meta {
  display: flex;
  gap: 16px;
  font-size: 12px;
  color: var(--ms-text-secondary);
}

.ms-portfolio-assets {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 12px;
}

/* ===== Hamburger Menu ===== */
.ms-mobile-menu-toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  width: 40px;
  height: 40px;
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 8px;
  margin-left: 8px;
  order: 999;
}

.ms-mobile-menu-toggle span {
  display: block;
  width: 24px;
  height: 2px;
  background: #fff;
  margin: 3px 0;
  transition: all 0.3s;
}

.ms-mobile-menu-toggle.active span:nth-child(1) {
  transform: rotate(45deg) translate(5px, 5px);
}

.ms-mobile-menu-toggle.active span:nth-child(2) {
  opacity: 0;
}

.ms-mobile-menu-toggle.active span:nth-child(3) {
  transform: rotate(-45deg) translate(7px, -6px);
}

/* Show/Hide utilities */
.desktop-only {
  display: inline-block;
}

.mobile-only {
  display: none !important;
}

/* Table scroll wrapper */
.ms-data-table-wrapper,
.ms-table-wrapper {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  position: relative;
  border: 1px solid var(--ms-border);
  border-radius: 4px;
}

.ms-data-table-wrapper .ms-data-table,
.ms-table-wrapper .ms-data-table {
  min-width: 100%;
  border: none;
}

/* Table scroll hint indicator */
.ms-data-table-wrapper.is-scrollable::after,
.ms-table-wrapper.is-scrollable::after {
  content: '';
  position: absolute;
  top: 50%;
  right: 8px;
  transform: translateY(-50%);
  width: 32px;
  height: 32px;
  background: rgba(0, 51, 102, 0.8);
  border-radius: 50%;
  animation: scrollHint 1.5s ease-in-out infinite;
  pointer-events: none;
  z-index: 20;
}

@keyframes scrollHint {
  0%, 100% {
    opacity: 0;
    transform: translateY(-50%) translateX(0);
  }
  50% {
    opacity: 1;
    transform: translateY(-50%) translateX(-8px);
  }
}

/* Touch feedback for mobile */
@media (hover: none) {
  .ms-btn:active,
  .ms-nav-item:active,
  .ms-dropdown-item:active,
  .ms-option:active,
  .ms-subnav-item:active {
    opacity: 0.7;
  }
  
  .ms-fund-name .name:active {
    color: var(--ms-orange);
  }
  
  .ms-portfolio-card:active {
    border-color: var(--ms-blue);
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
    transform: scale(0.99);
  }
}

/* ===== 响应式 ===== */

/* Tablet and small desktop (1024px - 1200px) */
@media (max-width: 1200px) {
  .ms-metrics-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* Tablet (768px - 1024px) */
@media (max-width: 1024px) {
  .ms-header {
    padding: 0 16px;
  }
  
  .ms-header-left {
    gap: 16px;
  }
  
  .ms-nav-item {
    padding: 0 16px;
    font-size: 13px;
  }
  
  .ms-container {
    padding: 20px;
  }
  
  .ms-page-title {
    font-size: 24px;
  }
  
  /* Adjust metrics grid */
  .ms-metrics-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
  }
  
  /* Modal adjustments */
  .ms-modal {
    max-width: 90vw;
  }
}

/* Mobile Navigation and Layout (992px and below) */
@media (max-width: 992px) {
  /* Hide desktop navigation */
  .desktop-nav {
    display: none !important;
  }
  
  /* Mobile Navigation */
  .ms-mobile-menu-toggle {
    display: flex;
  }
  
  .mobile-nav {
    display: flex !important;
    position: fixed;
    top: 60px;
    left: 0;
    right: 0;
    background: var(--ms-blue);
    flex-direction: column;
    padding: 8px;
    gap: 0;
    transform: translateY(-100%);
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    z-index: 999;
    max-height: calc(100vh - 60px);
    overflow-y: auto;
    box-shadow: 0 4px 20px rgba(0,0,0,0.2);
  }
  
  .mobile-nav.show {
    transform: translateY(0);
    opacity: 1;
    visibility: visible;
  }
  
  .mobile-nav .ms-nav-item {
    height: auto;
    padding: 14px 16px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    margin-bottom: 0;
    font-size: 14px;
  }
  
  .mobile-nav .ms-nav-item:last-child {
    border-bottom: none;
  }
  
  /* Mobile nav divider */
  .ms-nav-divider {
    height: 1px;
    background: rgba(255,255,255,0.2);
    margin: 8px 16px;
  }
  
  /* Mobile nav danger item (logout) */
  .ms-nav-item.danger {
    color: #ff9999;
  }
  
  .ms-nav-item.danger:hover {
    background: rgba(255,0,0,0.15);
  }
  
  .desktop-only {
    display: none !important;
  }
  
  .mobile-only {
    display: flex !important;
  }
  
  /* Mobile table with horizontal scroll */
  .ms-table-wrapper,
  .ms-data-table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    position: relative;
    border-radius: 4px;
  }
  
  .ms-table-wrapper .ms-data-table,
  .ms-data-table-wrapper .ms-data-table {
    min-width: 800px;
  }
  
  /* Sticky first column for better UX */
  .ms-table-wrapper .ms-data-table thead th:first-child,
  .ms-table-wrapper .ms-data-table tbody td:first-child,
  .ms-data-table-wrapper .ms-data-table thead th:first-child,
  .ms-data-table-wrapper .ms-data-table tbody td:first-child {
    position: sticky;
    left: 0;
    background: var(--ms-bg-light);
    z-index: 10;
    box-shadow: 2px 0 5px rgba(0,0,0,0.1);
  }
  
  .ms-table-wrapper .ms-data-table tbody td:first-child,
  .ms-data-table-wrapper .ms-data-table tbody td:first-child {
    background: #fff;
  }
  
  .ms-table-wrapper .ms-data-table tbody tr:hover td:first-child,
  .ms-data-table-wrapper .ms-data-table tbody tr:hover td:first-child {
    background: var(--ms-bg-hover);
  }
  
  /* Adjust search box */
  .ms-search-box input {
    width: 160px;
  }
  
  /* Subnav scrollable */
  .ms-subnav {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding: 0 16px;
  }
  
  .ms-subnav::-webkit-scrollbar {
    display: none;
  }
}

/* Mobile (768px and below) */
@media (max-width: 768px) {
  .ms-header {
    padding: 0 12px;
    height: 56px;
  }
  
  .ms-header-left {
    gap: 8px;
    flex: 0 0 auto;
  }
  
  .ms-header-center {
    flex: 1;
    padding: 0 8px;
    min-width: 0;
  }
  
  .ms-header-center .ms-search-box {
    display: block;
    width: 100%;
  }
  
  .ms-header-center .ms-search-box input {
    width: 100%;
    min-width: 0;
  }
  
  .ms-logo {
    font-size: 20px;
  }
  
  .ms-header-right .ms-search-box {
    display: none;
  }
  
  .ms-header-right {
    gap: 8px;
  }
  
  .ms-user-btn {
    padding: 4px 8px;
  }
  
  .ms-user-avatar {
    width: 28px;
    height: 28px;
    font-size: 11px;
  }
  
  .ms-subnav {
    padding: 0 12px;
    height: auto;
    min-height: 48px;
  }
  
  .ms-subnav-item {
    padding: 12px 14px;
    font-size: 12px;
    white-space: nowrap;
  }
  
  .ms-container {
    padding: 16px 12px;
  }
  
  .ms-page-header {
    margin-bottom: 16px;
    padding-bottom: 16px;
  }
  
  .ms-page-title {
    font-size: 20px;
  }
  
  .ms-page-subtitle {
    font-size: 13px;
  }
  
  .ms-breadcrumb {
    font-size: 11px;
    margin-bottom: 12px;
    flex-wrap: wrap;
  }
  
  /* Compact tables */
  .ms-data-table {
    font-size: 12px;
  }
  
  .ms-data-table thead th,
  .ms-data-table tbody td {
    padding: 10px 8px;
  }
  
  .ms-fund-name {
    gap: 2px;
  }
  
  .ms-fund-name .name {
    font-size: 12px;
  }
  
  .ms-fund-name .ticker {
    font-size: 10px;
  }
  
  .ms-fund-name .category {
    font-size: 10px;
  }
  
  /* Metrics grid */
  .ms-metrics-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    margin-bottom: 16px;
  }
  
  .ms-metric-card {
    padding: 12px 8px;
  }
  
  .ms-metric-card .label {
    font-size: 10px;
    margin-bottom: 6px;
  }
  
  .ms-metric-card .value {
    font-size: 16px;
  }
  
  .ms-metric-card .change {
    font-size: 11px;
  }
  
  /* Filter bar */
  .ms-filter-bar {
    flex-direction: column;
    gap: 12px;
    align-items: stretch;
    padding: 12px;
    margin-bottom: 16px;
  }
  
  .ms-filter-left {
    flex-direction: column;
    gap: 10px;
  }
  
  .ms-filter-select {
    width: 100%;
  }
  
  .ms-btn {
    width: 100%;
    justify-content: center;
  }
  
  /* User dropdown */
  .ms-dropdown {
    right: -5px;
    min-width: 260px;
    max-width: calc(100vw - 24px);
  }
  
  /* Modal adjustments */
  .ms-modal-overlay {
    padding: 12px;
    align-items: flex-end;
  }
  
  .ms-modal {
    max-width: 100%;
    max-height: calc(100vh - 24px);
    margin: 0;
    border-radius: 12px 12px 8px 8px;
  }
  
  .ms-modal-header {
    padding: 16px 16px 0;
  }
  
  .ms-modal-header h2 {
    font-size: 18px;
  }
  
  .ms-modal-header p {
    font-size: 13px;
  }
  
  .ms-modal-body {
    padding: 16px;
  }
  
  .ms-modal-footer {
    padding: 12px 16px 16px;
    flex-direction: column-reverse;
    gap: 8px;
  }
  
  .ms-modal-footer .ms-btn {
    width: 100%;
  }
  
  /* Questionnaire */
  .ms-question {
    margin-bottom: 20px;
    padding-bottom: 20px;
  }
  
  .ms-question h4 {
    font-size: 13px;
    line-height: 1.5;
  }
  
  .ms-option {
    padding: 10px 12px;
    font-size: 12px;
  }
  
  /* Portfolio cards */
  .ms-portfolio-card {
    padding: 16px;
  }
  
  .ms-portfolio-header {
    flex-direction: column;
    gap: 8px;
  }
  
  .ms-portfolio-name {
    font-size: 14px;
  }
  
  .ms-portfolio-value {
    font-size: 18px;
  }
  
  .ms-portfolio-meta {
    flex-wrap: wrap;
    gap: 8px 16px;
  }
  
  /* Detail page */
  .ms-detail-header {
    padding: 16px;
    margin-bottom: 16px;
  }
  
  .ms-detail-title {
    flex-direction: column;
    gap: 12px;
  }
  
  .ms-detail-title h1 {
    font-size: 20px;
  }
  
  .ms-detail-meta {
    gap: 12px;
    margin-top: 12px;
  }
  
  .ms-meta-item {
    font-size: 12px;
  }
  
  /* Chart containers */
  .ms-chart-container {
    padding: 16px;
    margin-bottom: 16px;
  }
  
  .ms-chart-container h3 {
    font-size: 14px;
    margin-bottom: 16px;
  }
  
  /* Empty state */
  .ms-empty {
    padding: 60px 20px;
  }
  
  .ms-empty-icon {
    font-size: 36px;
  }
  
  .ms-empty h3 {
    font-size: 16px;
  }
  
  /* Lock notice */
  .ms-lock-notice {
    padding: 40px 20px;
  }
  
  .ms-lock-notice-icon {
    font-size: 40px;
  }
  
  .ms-lock-notice h3 {
    font-size: 16px;
  }
  
  .ms-lock-notice p {
    font-size: 13px;
  }
}

/* Small Mobile (480px and below) */
@media (max-width: 480px) {
  .ms-header {
    padding: 0 10px;
    height: 52px;
  }
  
  .ms-logo {
    font-size: 18px;
  }
  
  .ms-mobile-menu-toggle {
    width: 36px;
    height: 36px;
    padding: 6px;
  }
  
  .ms-mobile-menu-toggle span {
    width: 20px;
    height: 2px;
    margin: 2px 0;
  }
  
  .ms-user-avatar {
    width: 26px;
    height: 26px;
    font-size: 10px;
  }
  
  .ms-nav {
    top: 52px;
    max-height: calc(100vh - 52px);
  }
  
  .ms-nav-item {
    padding: 12px 14px;
    font-size: 13px;
  }
  
  .ms-container {
    padding: 12px 10px;
  }
  
  .ms-page-title {
    font-size: 18px;
  }
  
  .ms-page-subtitle {
    font-size: 12px;
  }
  
  /* Metrics grid single column for very small screens */
  .ms-metrics-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }
  
  .ms-metric-card {
    padding: 10px 6px;
  }
  
  .ms-metric-card .label {
    font-size: 9px;
  }
  
  .ms-metric-card .value {
    font-size: 14px;
  }
  
  /* Tables */
  .ms-data-table {
    font-size: 11px;
  }
  
  .ms-data-table thead th,
  .ms-data-table tbody td {
    padding: 8px 6px;
  }
  
  /* Tags */
  .ms-tag {
    font-size: 10px;
    padding: 2px 6px;
  }
  
  /* Star rating */
  .ms-star {
    font-size: 12px;
  }
  
  /* Modal */
  .ms-modal-header h2 {
    font-size: 16px;
  }
  
  .ms-option {
    padding: 8px 10px;
  }
  
  .ms-option input {
    width: 14px;
    height: 14px;
  }
  
  /* Form elements */
  .ms-form-group {
    margin-bottom: 16px;
  }
  
  .ms-form-group label {
    font-size: 12px;
    margin-bottom: 4px;
  }
  
  .ms-form-group input,
  .ms-form-group textarea {
    padding: 10px 12px;
    font-size: 13px;
  }
  
  /* Dropdown */
  .ms-dropdown-item {
    padding: 10px 12px;
    font-size: 12px;
  }
}

/* Extra Small Mobile (360px and below) */
@media (max-width: 360px) {
  .ms-logo {
    font-size: 16px;
  }
  
  .ms-metrics-grid {
    grid-template-columns: 1fr;
    gap: 8px;
  }
  
  .ms-metric-card {
    padding: 12px;
  }
}

/* 隐藏元素 */
.hidden {
  display: none !important;
}


/* ===== Landing Page Styles ===== */

/* Market Pulse Section */
.market-pulse-section {
  margin-bottom: 40px;
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.section-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--ms-dark);
}

.time-range-selector {
  padding: 8px 16px;
  border: 1px solid var(--ms-border);
  border-radius: 4px;
  background: #fff;
  font-size: 13px;
  cursor: pointer;
  min-width: 150px;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23666' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 32px;
}

.heatmap-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 20px;
}

.heatmap-card {
  background: #fff;
  border: 1px solid var(--ms-border);
  border-radius: 8px;
  padding: 20px;
}

.heatmap-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--ms-text);
  margin-bottom: 16px;
  text-align: center;
}

.heatmap-container {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  justify-content: center;
}

.heatmap-cell {
  width: 70px;
  height: 50px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  font-size: 11px;
  cursor: pointer;
  transition: transform 0.2s;
}

.heatmap-cell:hover {
  transform: scale(1.05);
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.heatmap-cell .label {
  font-weight: 600;
  margin-bottom: 2px;
  font-size: 10px;
  text-align: center;
  line-height: 1.2;
}

.heatmap-cell .value {
  font-family: var(--font-mono);
  font-size: 10px;
}

/* Positive returns - green shades */
.heatmap-cell.pos-high { background: #1e7e34; color: #fff; }
.heatmap-cell.pos-medium { background: #4caf50; color: #fff; }
.heatmap-cell.pos-low { background: #a5d6a7; color: #1b5e20; }

/* Negative returns - red shades */
.heatmap-cell.neg-high { background: #c62828; color: #fff; }
.heatmap-cell.neg-medium { background: #ef5350; color: #fff; }
.heatmap-cell.neg-low { background: #ffcdd2; color: #b71c1c; }

/* Neutral */
.heatmap-cell.neutral { background: #e0e0e0; color: #666; }

/* Data Tables Section */
.data-tables-section {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}

.data-table-card {
  background: #fff;
  border: 1px solid var(--ms-border);
  border-radius: 8px;
  padding: 20px;
}

.data-table-card .card-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--ms-dark);
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 2px solid var(--ms-orange);
}

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

.landing-data-table th {
  background: var(--ms-bg-light);
  padding: 12px 10px;
  text-align: left;
  font-weight: 600;
  color: var(--ms-text);
  border-bottom: 2px solid var(--ms-border);
  font-size: 12px;
}

.landing-data-table td {
  padding: 12px 10px;
  border-bottom: 1px solid var(--ms-border-light);
}

.landing-data-table tr:hover {
  background: var(--ms-bg-hover);
}

.landing-data-table .index-name {
  font-weight: 600;
  color: var(--ms-blue-light);
}

.landing-data-table .category {
  font-size: 11px;
  color: var(--ms-text-secondary);
}

.score-badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
  font-family: var(--font-mono);
}

.score-high { background: #e8f5e9; color: #2e7d32; }
.score-medium { background: #fff3e0; color: #ef6c00; }
.score-low { background: #ffebee; color: #c62828; }

.return-positive { color: var(--ms-green); }
.return-negative { color: var(--ms-red); }

/* Landing Page - World Stock Market */
.world-stock-container {
  position: relative;
}

.world-stock-legend {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 20px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--ms-border-light);
}

.legend-gradient {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--ms-text-secondary);
}

.gradient-bar {
  width: 120px;
  height: 12px;
  background: linear-gradient(to right, #c62828, #ef5350, #ffcdd2, #e0e0e0, #a5d6a7, #4caf50, #1e7e34);
  border-radius: 2px;
}

/* Landing Page Responsive */
@media (max-width: 1200px) {
  .heatmap-grid {
    grid-template-columns: 1fr 1fr;
    gap: 16px;
  }
  
  .heatmap-grid > div:last-child {
    grid-column: 1 / -1;
  }
  
  .data-tables-section {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  .heatmap-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }
  
  .heatmap-card {
    padding: 16px;
  }
  
  .heatmap-title {
    font-size: 13px;
    margin-bottom: 12px;
  }
  
  #worldStockMarketMap {
    height: 280px !important;
  }
  
  .world-stock-legend {
    flex-direction: column;
    gap: 8px;
  }
}

@media (max-width: 768px) {
  .heatmap-cell {
    width: 60px;
    height: 45px;
    font-size: 9px;
  }
  
  .heatmap-cell .label {
    font-size: 9px;
  }
  
  .heatmap-cell .value {
    font-size: 9px;
  }
  
  .section-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }
  
  .landing-data-table {
    font-size: 12px;
  }
  
  .landing-data-table th,
  .landing-data-table td {
    padding: 8px 6px;
  }
}

/* ===== Pagination ===== */
.ms-pagination {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 0;
  margin-top: 8px;
  border-top: 1px solid var(--ms-border);
  flex-wrap: wrap;
  gap: 12px;
}

.ms-pagination-info {
  font-size: 13px;
  color: var(--ms-text-secondary);
}

.ms-pagination-info span {
  margin: 0 2px;
}

.ms-pagination-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.ms-pagination-pages {
  display: flex;
  gap: 4px;
}

.ms-page-btn {
  min-width: 32px;
  height: 32px;
  padding: 0 8px;
  border: 1px solid var(--ms-border);
  border-radius: 4px;
  background: #fff;
  color: var(--ms-text);
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.ms-page-btn:hover:not(:disabled) {
  background: var(--ms-bg-light);
  border-color: var(--ms-blue);
  color: var(--ms-blue);
}

.ms-page-btn.active {
  background: var(--ms-blue);
  border-color: var(--ms-blue);
  color: #fff;
  font-weight: 600;
}

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

.ms-page-btn.ellipsis {
  border: none;
  background: transparent;
  cursor: default;
  pointer-events: none;
}

/* Small button variant */
.ms-btn-sm {
  padding: 6px 12px;
  font-size: 12px;
}

/* ===== Sortable Table Headers ===== */
.ms-data-table thead th.sortable {
  cursor: pointer;
  user-select: none;
  position: relative;
  padding-right: 24px;
}

.ms-data-table thead th.sortable:hover {
  background: var(--ms-border-light);
}

.ms-data-table thead th.sortable::after {
  content: '↕';
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 12px;
  color: var(--ms-text-muted);
  opacity: 0.5;
}

.ms-data-table thead th.sortable.asc::after {
  content: '↑';
  opacity: 1;
  color: var(--ms-blue);
}

.ms-data-table thead th.sortable.desc::after {
  content: '↓';
  opacity: 1;
  color: var(--ms-blue);
}

/* ===== Portfolio Pagination ===== */
.ms-portfolio-pagination {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px;
  margin-top: 16px;
  background: var(--ms-bg-light);
  border-radius: 4px;
  flex-wrap: wrap;
  gap: 12px;
}

/* Mobile Pagination */
@media (max-width: 768px) {
  .ms-pagination {
    flex-direction: column;
    align-items: stretch;
    padding: 12px 0;
  }
  
  .ms-pagination-info {
    text-align: center;
    font-size: 12px;
  }
  
  .ms-pagination-controls {
    justify-content: center;
    flex-wrap: wrap;
  }
  
  .ms-page-btn {
    min-width: 36px;
    height: 36px;
    font-size: 14px;
  }
  
  .ms-btn-sm {
    padding: 8px 16px;
    font-size: 13px;
  }
  
  .ms-portfolio-pagination {
    flex-direction: column;
    align-items: stretch;
    text-align: center;
  }
}

@media (max-width: 480px) {
  .ms-pagination-pages {
    display: none;
  }
  
  .ms-pagination-controls {
    justify-content: space-between;
    width: 100%;
  }
  
  .ms-pagination-controls .ms-btn {
    flex: 1;
  }
}

/* AI Icon for Terminology Explanation */
.ai-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  background: linear-gradient(135deg, #0066cc, #0099ff);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  border-radius: 4px;
  margin-left: 8px;
  cursor: pointer;
  vertical-align: middle;
  transition: all 0.2s ease;
  box-shadow: 0 2px 4px rgba(0, 102, 204, 0.3);
  font-family: var(--font-primary);
  letter-spacing: 0.5px;
}

.ai-icon:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(0, 102, 204, 0.4);
  background: linear-gradient(135deg, #0055aa, #0088ee);
}

.ai-icon:active {
  transform: translateY(0);
  box-shadow: 0 2px 4px rgba(0, 102, 204, 0.3);
}

/* Terminology Modal Styles */
.terminology-modal {
  max-width: 480px;
}

.terminology-modal .ms-modal-body {
  padding: 24px;
}

.terminology-content h3 {
  font-size: 18px;
  font-weight: 700;
  color: var(--ms-dark);
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 2px solid var(--ms-blue-light);
}

.terminology-content p {
  font-size: 14px;
  line-height: 1.8;
  color: var(--ms-text);
}

/* Card title with AI icon */
.card-title {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
}

.card-title span:first-child {
  margin-right: 4px;
}

/* Additional styles for fund detail page */

/* AI Icon for Fund Detail */
.ai-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  background: linear-gradient(135deg, #0066cc, #0099ff);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  border-radius: 4px;
  cursor: pointer;
  vertical-align: middle;
  transition: all 0.2s ease;
  box-shadow: 0 2px 4px rgba(0, 102, 204, 0.3);
  font-family: var(--font-primary);
  letter-spacing: 0.5px;
}

.ai-icon:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(0, 102, 204, 0.4);
  background: linear-gradient(135deg, #0055aa, #0088ee);
}

/* Period header for tables */
.period-header {
  background: #666 !important;
  color: #fff !important;
}

/* Status colors */
.status-red {
  color: var(--ms-red) !important;
  font-weight: 600;
}

.status-orange {
  color: var(--ms-orange) !important;
  font-weight: 600;
}

.status-green {
  color: var(--ms-green) !important;
  font-weight: 600;
}

/* Simple header layout */
.ms-header-simple .ms-header-left {
  flex: 0 0 auto;
}

/* Region button states */
.region-btn.active {
  background: var(--ms-blue);
  color: #fff;
  border-color: var(--ms-blue);
  font-weight: 600;
}

.region-btn:disabled,
.region-btn[disabled] {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
}

/* Score badges for Return & Risk table */
.score-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  font-size: 13px;
  font-weight: 700;
  color: #333;
}

.score-poor {
  background-color: #ffcccc;
}

.score-medium {
  background-color: #ffe0b3;
}

.score-good {
  background-color: #ccffcc;
}

.score-excellent {
  background-color: #66cc66;
}

.score-gray {
  background-color: #e0e0e0;
  color: #999;
}

.score-na {
  background-color: #e8e8e8;
}

/* ===== Login Page Mobile Optimizations ===== */
@media (max-width: 480px) {
  .ms-login-box {
    padding: 24px 20px;
    margin: 16px;
    max-width: calc(100vw - 32px);
  }
  
  .ms-login-header .logo {
    font-size: 24px;
  }
  
  .ms-login-header p {
    font-size: 13px;
  }
  
  .ms-login-footer {
    margin-top: 20px;
    padding-top: 20px;
  }
  
  .ms-login-footer p {
    font-size: 11px;
  }
}

/* ===== Landing Page Mobile Optimizations ===== */
@media (max-width: 768px) {
  .market-pulse-section {
    margin-bottom: 24px;
  }
  
  .section-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 16px;
  }
  
  .section-title {
    font-size: 18px;
  }
  
  .time-range-selector {
    width: 100%;
    min-width: unset;
  }
  
  .heatmap-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }
  
  .heatmap-card {
    padding: 16px;
  }
  
  .heatmap-title {
    font-size: 14px;
    margin-bottom: 12px;
  }
  
  .heatmap-cell {
    width: calc(25% - 3px);
    height: 48px;
    min-width: 60px;
  }
  
  .heatmap-cell .label {
    font-size: 10px;
  }
  
  .heatmap-cell .value {
    font-size: 9px;
  }
  
  /* Style grid adjustments */
  .style-grid-wrapper {
    flex-direction: column;
    align-items: center;
  }
  
  .style-grid-labels.left {
    flex-direction: row;
    width: 200px;
    height: auto;
    margin-right: 0;
    margin-bottom: 4px;
  }
  
  .style-grid-labels.left span {
    writing-mode: horizontal-tb !important;
    text-orientation: mixed !important;
    flex: 1;
    font-size: 10px;
  }
  
  .style-grid {
    width: 200px;
    height: 200px;
  }
  
  /* Diamond grid adjustments */
  .sector-diamond-container {
    padding: 20px 10px;
  }
  
  .diamond-grid {
    width: 200px;
    height: 200px;
  }
  
  .diamond {
    width: 70px;
    height: 70px;
  }
  
  .diamond-sensory { top: 10px; left: 65px; }
  .diamond-defensive { bottom: 10px; left: 65px; }
  .diamond-cyclical { top: 65px; left: 10px; }
  .diamond-tech { top: 65px; right: 10px; }
  
  .diamond-label {
    font-size: 12px;
  }
  
  .diamond-value {
    font-size: 10px;
  }
  
  /* Data tables */
  .data-tables-section {
    gap: 16px;
  }
  
  .data-table-card {
    padding: 16px;
  }
  
  .data-table-card .card-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
  }
  
  .data-table-card .card-title {
    font-size: 14px;
  }
  
  .data-table-card .card-desc {
    font-size: 12px;
  }
  
  .landing-data-table {
    font-size: 11px;
  }
  
  .landing-data-table th,
  .landing-data-table td {
    padding: 8px 6px;
  }
  
  .score-badge {
    padding: 2px 6px;
    font-size: 10px;
  }
  
  /* World stock map */
  #worldStockMarketMap {
    height: 240px !important;
  }
  
  .world-stock-legend {
    flex-direction: column;
    gap: 8px;
    font-size: 11px;
  }
  
  .gradient-bar {
    width: 100px;
    height: 10px;
  }
}

@media (max-width: 480px) {
  .heatmap-cell {
    width: calc(33.333% - 3px);
    height: 44px;
    min-width: unset;
  }
  
  .heatmap-cell .label {
    font-size: 9px;
  }
  
  .diamond-grid {
    width: 180px;
    height: 180px;
  }
  
  .diamond {
    width: 60px;
    height: 60px;
  }
  
  .diamond-sensory { top: 10px; left: 60px; }
  .diamond-defensive { bottom: 10px; left: 60px; }
  .diamond-cyclical { top: 60px; left: 10px; }
  .diamond-tech { top: 60px; right: 10px; }
  
  .diamond-label {
    font-size: 11px;
  }
  
  .diamond-value {
    font-size: 9px;
  }
  
  .style-grid {
    width: 180px;
    height: 180px;
  }
  
  .style-grid-labels.left {
    width: 180px;
  }
}

/* ===== Fund Detail Page Mobile Optimizations ===== */
@media (max-width: 768px) {
  .fund-detail-container {
    padding: 16px 12px;
  }
  
  .fund-header-section {
    margin-bottom: 20px;
  }
  
  .fund-title {
    font-size: 20px;
    margin-bottom: 12px;
  }
  
  .fund-info-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px 16px;
    margin-bottom: 16px;
  }
  
  .fund-info-item {
    flex-direction: column;
    gap: 2px;
  }
  
  .fund-info-label {
    font-size: 11px;
  }
  
  .fund-info-value {
    font-size: 12px;
  }
  
  /* Key metrics - horizontal scroll */
  .key-metrics {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 4px;
    scrollbar-width: none;
  }
  
  .key-metrics::-webkit-scrollbar {
    display: none;
  }
  
  .metric-box {
    flex: 0 0 auto;
    min-width: 80px;
    padding: 12px 14px;
  }
  
  .metric-label {
    font-size: 10px;
  }
  
  .metric-value {
    font-size: 16px;
  }
  
  .metric-date {
    font-size: 9px;
  }
  
  /* Content sections */
  .content-section {
    padding: 16px;
    margin-bottom: 16px;
    border-radius: 6px;
  }
  
  .section-title {
    font-size: 14px;
    margin-bottom: 12px;
  }
  
  /* Return & Risk */
  .return-risk-grid {
    flex-direction: column;
    gap: 16px;
  }
  
  .table-wrapper,
  .chart-wrapper {
    flex: 1 1 100%;
  }
  
  .data-table {
    font-size: 12px;
  }
  
  .data-table th,
  .data-table td {
    padding: 10px 8px;
  }
  
  #returnChart {
    height: 260px !important;
  }
  
  /* Risk Exposure */
  .risk-exposure-section {
    margin-top: 16px;
  }
  
  .exposure-charts {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin-top: 12px;
  }
  
  .exposure-chart-item {
    padding: 8px 0;
  }
  
  .exposure-chart {
    height: 120px;
  }
  
  .exposure-chart-label {
    font-size: 11px;
    margin-top: 4px;
  }
  
  /* Scores */
  .scores-section {
    gap: 12px;
  }
  
  .score-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    padding: 12px 14px;
  }
  
  .score-label {
    font-size: 13px;
  }
  
  .score-value {
    font-size: 16px;
  }
  
  .score-desc {
    font-size: 12px;
    line-height: 1.5;
  }
  
  /* Hypothesis */
  .hypothesis-section {
    grid-template-columns: 1fr;
    gap: 20px;
    margin-top: 16px;
  }
  
  .slider-container {
    padding: 0 8px;
  }
  
  .slider-header {
    margin-bottom: 12px;
  }
  
  .slider-value {
    font-size: 16px;
    margin: 8px 0;
  }
  
  .hypothesis-btn-group {
    margin-top: 16px;
  }
  
  .hypothesis-btn {
    padding: 10px 16px;
    font-size: 13px;
  }
  
  /* Health table */
  .health-table {
    font-size: 12px;
  }
  
  .health-table th,
  .health-table td {
    padding: 8px 10px;
  }
  
  /* Disclaimer */
  .disclaimer-section {
    padding: 24px 16px;
    margin-top: 24px;
  }
  
  .disclaimer-title {
    font-size: 13px;
  }
  
  .disclaimer-text {
    font-size: 11px;
  }
  
  .date-label {
    font-size: 10px;
    margin-bottom: 6px;
  }
}

@media (max-width: 480px) {
  .fund-title {
    font-size: 18px;
  }
  
  .fund-info-grid {
    grid-template-columns: 1fr;
    gap: 8px;
  }
  
  .fund-info-item {
    flex-direction: row;
    justify-content: space-between;
    padding: 4px 0;
    border-bottom: 1px solid var(--ms-border-light);
  }
  
  .fund-info-item:last-child {
    border-bottom: none;
  }
  
  .exposure-charts {
    grid-template-columns: 1fr;
    gap: 16px;
  }
  
  .exposure-chart {
    height: 160px;
  }
}

/* ===== Portfolio Detail Page Mobile Optimizations ===== */
@media (max-width: 768px) {
  /* Two column charts to single column */
  main[style*="grid-template-columns: repeat(2, 1fr)"] {
    grid-template-columns: 1fr !important;
  }
  
  .ms-chart-container[style*="margin-bottom: 0"] {
    margin-bottom: 16px !important;
  }
  
  #performanceChart,
  #sectorChart,
  #geoChart {
    height: 240px !important;
  }
}

/* ===== Portfolio Trade Modal Styles ===== */

.ms-portfolio-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 12px;
}

.ms-btn-sm {
  padding: 6px 12px;
  font-size: 12px;
}

/* Trade Tabs */
.ms-trade-tabs {
  display: flex;
  gap: 0;
  border-bottom: 2px solid var(--ms-border);
  margin-bottom: 20px;
}

.ms-trade-tab {
  flex: 1;
  padding: 12px 16px;
  border: none;
  background: transparent;
  font-size: 14px;
  font-weight: 500;
  color: var(--ms-text-secondary);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: all 0.2s;
}

.ms-trade-tab:hover {
  color: var(--ms-blue);
  background: var(--ms-bg-light);
}

.ms-trade-tab.active {
  color: var(--ms-orange);
  border-bottom-color: var(--ms-orange);
  font-weight: 600;
}

/* Trade Forms */
.ms-trade-form {
  animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Fund Search Box */
.ms-search-fund-box {
  display: flex;
  gap: 8px;
}

.ms-search-fund-box input {
  flex: 1;
  padding: 10px 12px;
  border: 1px solid var(--ms-border);
  border-radius: 4px;
  font-size: 14px;
}

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

/* Fund Search Results */
.ms-fund-search-results {
  max-height: 200px;
  overflow-y: auto;
  border: 1px solid var(--ms-border);
  border-radius: 4px;
  margin-top: 8px;
  background: #fff;
}

.ms-fund-result-item {
  padding: 12px 16px;
  border-bottom: 1px solid var(--ms-border-light);
  cursor: pointer;
  transition: background 0.15s;
}

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

.ms-fund-result-item:hover {
  background: var(--ms-bg-hover);
}

.ms-fund-result-item .fund-name {
  font-weight: 600;
  color: var(--ms-blue-light);
  font-size: 14px;
  margin-bottom: 4px;
}

.ms-fund-result-item .fund-code {
  font-size: 12px;
  color: var(--ms-text-muted);
}

/* Selected Fund Info */
.ms-selected-fund {
  margin-top: 12px;
  padding: 12px 16px;
  background: var(--ms-bg-light);
  border-radius: 4px;
  border-left: 3px solid var(--ms-orange);
}

.ms-selected-fund .selected-fund-label {
  font-size: 11px;
  color: var(--ms-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}

.ms-selected-fund .selected-fund-name {
  font-weight: 600;
  color: var(--ms-dark);
  font-size: 14px;
  margin-bottom: 4px;
}

.ms-selected-fund .selected-fund-nav {
  font-size: 12px;
  color: var(--ms-text-secondary);
  font-family: var(--font-mono);
}

/* Input with unit */
.ms-input-with-unit {
  position: relative;
  display: flex;
  align-items: center;
}

.ms-input-with-unit input {
  flex: 1;
  padding: 10px 60px 10px 12px;
  border: 1px solid var(--ms-border);
  border-radius: 4px;
  font-size: 14px;
}

.ms-input-with-unit input:focus {
  outline: none;
  border-color: var(--ms-blue);
}

.ms-input-with-unit .input-unit {
  position: absolute;
  right: 12px;
  font-size: 13px;
  color: var(--ms-text-muted);
  font-weight: 500;
}

/* Readonly inputs */
.ms-input-readonly {
  background: var(--ms-bg-light) !important;
  color: var(--ms-text-secondary) !important;
  cursor: not-allowed;
}

/* Responsive adjustments for trade modal */
@media (max-width: 768px) {
  .ms-trade-tabs {
    font-size: 13px;
  }
  
  .ms-trade-tab {
    padding: 10px 8px;
  }
  
  .ms-form-row {
    flex-direction: column;
    gap: 0;
  }
  
  .ms-search-fund-box {
    flex-direction: column;
  }
  
  .ms-search-fund-box .ms-btn {
    width: 100%;
  }
}

/* ===== Return & Risk Table Scrollbar Styles ===== */

/* Firefox scrollbar support */
.data-table tbody {
  scrollbar-width: thin;
  scrollbar-color: #ccc transparent;
}

/* Ensure consistent row height */
.data-table tbody tr {
  height: 48px;
}

.data-table td {
  vertical-align: middle;
}

/* Desktop: ensure 6 rows fit without scrolling if data <= 6 */
@media (min-width: 769px) {
  .data-table tbody {
    max-height: 310px;
  }
}

/* ===== Fund Search Component Styles ===== */

.ms-fund-search-wrapper {
  position: relative;
  width: 100%;
}

.ms-fund-search-box {
  position: relative;
  display: flex;
  align-items: center;
}

.ms-fund-search-input {
  width: 280px;
  height: 36px;
  padding: 0 36px 0 12px;
  border: 1px solid rgba(255,255,255,0.3);
  border-radius: 4px;
  background: rgba(255,255,255,0.1);
  color: #fff;
  font-size: 13px;
  transition: all 0.2s;
}

.ms-fund-search-input::placeholder {
  color: rgba(255,255,255,0.6);
}

.ms-fund-search-input:focus {
  outline: none;
  border-color: var(--ms-orange);
  background: #fff;
  color: var(--ms-text);
}

.ms-fund-search-input:focus::placeholder {
  color: var(--ms-text-muted);
}

.ms-fund-search-icon {
  position: absolute;
  right: 10px;
  font-size: 14px;
  opacity: 0.6;
  pointer-events: none;
}

.ms-fund-search-input:focus + .ms-fund-search-icon {
  opacity: 0.8;
  color: var(--ms-text-muted);
}

/* Dropdown Styles */
.ms-fund-search-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  min-width: 360px;
  background: #fff;
  border: 1px solid var(--ms-border);
  border-radius: 8px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.15);
  z-index: 1100;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-8px);
  transition: all 0.2s ease;
  max-height: 400px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.ms-fund-search-dropdown.show {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

/* Loading State */
.ms-fund-search-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 24px;
  color: var(--ms-text-secondary);
  font-size: 13px;
}

.ms-fund-search-spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--ms-border-light);
  border-top-color: var(--ms-orange);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* Results List */
.ms-fund-search-results {
  overflow-y: auto;
  max-height: 360px;
}

.ms-fund-search-results::-webkit-scrollbar {
  width: 6px;
}

.ms-fund-search-results::-webkit-scrollbar-track {
  background: var(--ms-bg-light);
}

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

.ms-fund-search-results::-webkit-scrollbar-thumb:hover {
  background: var(--ms-text-muted);
}

/* Result Item */
.ms-fund-search-item {
  padding: 14px 16px;
  border-bottom: 1px solid var(--ms-border-light);
  cursor: pointer;
  transition: background 0.15s;
}

.ms-fund-search-item:last-child {
  border-bottom: none;
}

.ms-fund-search-item:hover {
  background: var(--ms-bg-hover);
}

.ms-fund-search-item:active {
  background: var(--ms-bg-light);
}

.ms-fund-search-item-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 6px;
}

.ms-fund-search-item-name {
  font-weight: 600;
  font-size: 14px;
  color: var(--ms-dark);
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ms-fund-search-item-type {
  font-size: 11px;
  padding: 2px 8px;
  background: var(--ms-bg-light);
  color: var(--ms-text-secondary);
  border-radius: 3px;
  white-space: nowrap;
}

.ms-fund-search-item-details {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.ms-fund-search-item-strategy {
  font-size: 12px;
  color: var(--ms-text-secondary);
}

.ms-fund-search-item-dates {
  display: flex;
  gap: 16px;
  font-size: 11px;
  color: var(--ms-text-muted);
}

.ms-fund-search-item-dates span {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

/* Load More State */
.ms-fund-search-load-more {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px;
  color: var(--ms-text-secondary);
  font-size: 12px;
  border-top: 1px solid var(--ms-border-light);
  background: var(--ms-bg-light);
}

.ms-fund-search-spinner-small {
  width: 16px;
  height: 16px;
  border: 2px solid var(--ms-border-light);
  border-top-color: var(--ms-orange);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

/* Empty State */
.ms-fund-search-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px 24px;
  color: var(--ms-text-secondary);
  font-size: 13px;
  gap: 8px;
}

.ms-fund-search-empty-icon {
  font-size: 32px;
  opacity: 0.5;
}

/* Mobile Header Center Override */
.ms-header-center .ms-fund-search-wrapper {
  width: 100%;
  max-width: 300px;
}

.ms-header-center .ms-fund-search-input {
  width: 100%;
}

.ms-header-center .ms-fund-search-dropdown {
  left: 0;
  right: auto;
  min-width: 320px;
}

/* Responsive Adjustments */
@media (max-width: 1024px) {
  .ms-fund-search-input {
    width: 200px;
  }
  
  .ms-fund-search-dropdown {
    min-width: 320px;
  }
}

@media (max-width: 768px) {
  .ms-header-center .ms-fund-search-wrapper {
    max-width: none;
  }
  
  .ms-header-center .ms-fund-search-dropdown {
    min-width: 280px;
    left: 50%;
    transform: translateX(-50%) translateY(-8px);
  }
  
  .ms-header-center .ms-fund-search-dropdown.show {
    transform: translateX(-50%) translateY(0);
  }
  
  .ms-fund-search-item {
    padding: 12px;
  }
  
  .ms-fund-search-item-name {
    font-size: 13px;
  }
  
  .ms-fund-search-item-dates {
    flex-direction: column;
    gap: 2px;
  }
}

@media (max-width: 480px) {
  .ms-fund-search-dropdown {
    min-width: 260px;
  }
  
  .ms-fund-search-item-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
  }
  
  .ms-fund-search-item-name {
    white-space: normal;
    line-height: 1.4;
  }
}

/* ===== End of Fund Search Component Styles ===== */
