﻿/* ===== Reset & Variables ===== */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
:root {
  --bg: #0A0A0F;
  --card: #111118;
  --card-layer: rgba(255,255,255,0.06);
  --primary: #00B578;
  --primary-grad: linear-gradient(135deg, #38D9A9, #00B578);
  --blue: #4A9EFF;
  --blue-grad: linear-gradient(135deg, #4A9EFF, #0066FF);
  --gold: #D4AF37;
  --text: #E0E0E0;
  --text-secondary: #888;
  --gain: #00B578;
  --loss: #FF4D4F;
  --warn: #FAAD14;
  --border: #1A1A22;
  --radius: 12px;
  --radius-lg: 16px;
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
}
html { font-size: 14px; }
body { font-family: var(--font); background: var(--bg); color: var(--text); line-height: 1.5; min-height: 100vh; overflow-x: hidden; -webkit-tap-highlight-color: transparent; }
a { color: var(--primary); text-decoration: none; }
button { cursor: pointer; font-family: inherit; border: none; outline: none; }
input { font-family: inherit; outline: none; border: none; }
img { display: block; }

/* ===== Utility ===== */
.hidden { display: none !important; }
.gain { color: var(--gain); }
.loss { color: var(--loss); }
.warn { color: var(--warn); }
.w-full { width: 100%; }
.rounded { border-radius: var(--radius); }
.rounded-lg { border-radius: var(--radius-lg); }
.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-lg); }

/* ===== Animations ===== */
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
@keyframes spin { to { transform: rotate(360deg); } }
.fade-in { animation: fadeIn 0.3s ease; }

/* ===== Toast ===== */
.toast-container { position: fixed; top: 16px; right: 16px; z-index: 9999; display: flex; flex-direction: column; gap: 6px; }
.toast {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 10px 14px; font-size: 13px; color: var(--text);
  box-shadow: 0 8px 32px rgba(0,0,0,0.4); animation: fadeIn 0.3s ease;
  max-width: 300px; border-left: 3px solid transparent;
}
.toast.success { border-left-color: var(--gain); }
.toast.error { border-left-color: var(--loss); }
.toast.info { border-left-color: var(--warn); }

/* ===== Auth Page ===== */
.auth-page {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  padding: 20px;
  background: radial-gradient(ellipse at 50% 0%, rgba(0,181,120,0.1) 0%, transparent 60%);
}
.auth-box { width: 100%; max-width: 380px; padding: 24px; }
.auth-logo .logo-icon { font-size: 48px; margin-bottom: 8px; }
.auth-input-group { margin-bottom: 12px; }
.auth-input-group label { font-size: 12px; font-weight: 600; color: var(--text-secondary); display: block; margin-bottom: 5px; }
.auth-input {
  width: 100%; padding: 11px 14px; background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--radius); color: var(--text); font-size: 14px; transition: border-color 0.2s;
}
.auth-input:focus { border-color: var(--primary); }
.auth-input::placeholder { color: #555; }
.auth-toggle { text-align: center; margin-top: 14px; font-size: 13px; color: var(--text-secondary); }
.auth-toggle a { color: var(--primary); font-weight: 600; cursor: pointer; }
.auth-toggle a:hover { text-decoration: underline; }
.auth-error { color: var(--loss); font-size: 12px; margin-top: 8px; text-align: center; }

/* ===== Buttons ===== */
.btn-primary {
  background: var(--primary-grad); color: #fff; font-weight: 700;
  padding: 11px 20px; border-radius: var(--radius); font-size: 14px;
  transition: opacity 0.2s;
}
.btn-primary:hover { opacity: 0.88; }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-outline {
  background: transparent; color: var(--primary); border: 1.5px solid var(--primary);
  padding: 7px 14px; border-radius: var(--radius); font-size: 12px; font-weight: 600;
}
.btn-outline:hover { background: rgba(0,181,120,0.1); }
.btn-danger { background: var(--loss); color: #fff; padding: 7px 14px; border-radius: var(--radius); font-size: 12px; font-weight: 600; }
.btn-sm { padding: 6px 12px; font-size: 11px; border-radius: 8px; }

/* ===== Main Layout ===== */
.app-layout { display: flex; flex-direction: column; min-height: 100vh; }
.app-header {
  position: sticky; top: 0; z-index: 100;
  background: rgba(10,10,15,0.9); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border); padding: 10px 16px;
  display: flex; align-items: center; justify-content: space-between;
}
.app-header h1 { font-size: 16px; font-weight: 800; background: var(--primary-grad); -webkit-background-clip: text; -webkit-text-fill-color: transparent; }
.header-right { display: flex; align-items: center; gap: 8px; }
.market-badge {
  font-size: 10px; font-weight: 600; padding: 3px 8px;
  border-radius: 6px; display: flex; align-items: center; gap: 4px;
}
.market-badge .dot { width: 6px; height: 6px; border-radius: 50%; display: inline-block; }
.market-badge.open { background: rgba(0,181,120,0.15); color: var(--gain); }
.market-badge.open .dot { background: var(--gain); }
.market-badge.closed { background: rgba(255,255,255,0.05); color: var(--text-secondary); }
.market-badge.closed .dot { background: var(--text-secondary); }

.app-content { flex: 1; padding: 12px 16px 80px; max-width: 800px; width: 100%; margin: 0 auto; }

/* ===== Tab Bar ===== */
.tab-bar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 100;
  background: rgba(17,17,24,0.95); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--border);
  display: flex; justify-content: space-around;
  padding: 6px 0 max(6px, env(safe-area-inset-bottom));
}
.tab-item {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  background: none; color: var(--text-secondary); font-size: 10px; font-weight: 500;
  padding: 4px 10px; border-radius: 8px; transition: color 0.2s;
}
.tab-item.active { color: var(--primary); }
.tab-item .tab-icon { font-size: 20px; line-height: 1; }

/* ===== Dashboard ===== */
.dashboard-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.dashboard-header h2 { font-size: 18px; font-weight: 700; }
.sort-row { display: flex; gap: 6px; margin-bottom: 10px; flex-wrap: wrap; }
.sort-btn {
  padding: 5px 10px; border-radius: 7px; font-size: 11px; font-weight: 600;
  background: var(--card); color: var(--text-secondary); border: 1px solid var(--border);
  transition: all 0.2s;
}
.sort-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.profit-bar {
  display: flex; align-items: center; justify-content: space-between;
  background: linear-gradient(135deg, rgba(0,181,120,0.12), rgba(0,181,120,0.04));
  border: 1px solid rgba(0,181,120,0.15); border-radius: var(--radius);
  padding: 10px 14px; margin-bottom: 12px;
}
.profit-bar .label { font-size: 11px; color: var(--text-secondary); }
.profit-bar .value { font-size: 20px; font-weight: 800; }
.fund-list { display: flex; flex-direction: column; gap: 8px; }
.fund-card {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 14px; cursor: pointer; transition: transform 0.1s;
}
.fund-card:active { transform: scale(0.985); }
.fund-info { display: flex; flex-direction: column; gap: 2px; }
.fund-name { font-size: 14px; font-weight: 600; }
.fund-meta { font-size: 11px; color: var(--text-secondary); display: flex; align-items: center; gap: 6px; }
.fund-type-badge {
  font-size: 9px; padding: 1px 6px; border-radius: 4px; font-weight: 600;
}
.fund-type-badge.holding { background: rgba(0,181,120,0.15); color: var(--gain); }
.fund-type-badge.watchlist { background: rgba(74,158,255,0.15); color: var(--blue); }
.fund-change { text-align: right; }
.fund-change .pct { font-size: 16px; font-weight: 700; }
.fund-change .amount { font-size: 11px; }
.empty-state { text-align: center; padding: 40px 20px; color: var(--text-secondary); font-size: 13px; }

/* ===== Portfolio ===== */
.portfolio-summary {
  background: var(--primary-grad); border-radius: var(--radius-lg);
  padding: 18px; margin-bottom: 14px; position: relative; overflow: hidden;
}
.portfolio-summary::before {
  content: ''; position: absolute; top: -40px; right: -30px;
  width: 160px; height: 160px; border-radius: 50%;
  background: rgba(255,255,255,0.08);
}
.portfolio-summary .label { font-size: 12px; opacity: 0.7; }
.portfolio-summary .total { font-size: 30px; font-weight: 800; margin: 6px 0 4px; }
.portfolio-summary .profit-info { font-size: 13px; opacity: 0.9; display: flex; gap: 16px; flex-wrap: wrap; }
.holding-list { display: flex; flex-direction: column; gap: 8px; }
.holding-card {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px;
}
.holding-info { flex: 1; }
.holding-info .name { font-size: 14px; font-weight: 600; }
.holding-info .meta { font-size: 11px; color: var(--text-secondary); margin-top: 2px; }
.holding-values { text-align: right; }
.holding-values .cost { font-size: 13px; font-weight: 600; }
.holding-values .profit { font-size: 15px; font-weight: 700; margin-top: 2px; }
.holding-actions { display: flex; gap: 6px; margin-left: 10px; }

/* ===== AI Page ===== */
.ai-section { margin-bottom: 14px; }
.ai-section-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.ai-section-header h3 { font-size: 14px; font-weight: 700; }
.ai-section-header .meta { font-size: 10px; color: var(--text-secondary); }
.sector-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 12px; border-radius: 8px; margin-bottom: 4px;
  background: var(--card-layer); cursor: pointer; transition: background 0.15s;
}
.sector-item:hover { background: rgba(255,255,255,0.1); }
.sector-item .name { font-size: 13px; display: flex; align-items: center; gap: 4px; }
.sector-item .flow { font-size: 12px; font-weight: 600; }
.rec-item {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px;
  border-bottom: 1px solid var(--card-layer);
}
.rec-item:last-child { border-bottom: none; }
.rec-item .rank { font-size: 12px; font-weight: 700; color: var(--primary); width: 18px; text-align: center; }
.rec-item .info { flex: 1; }
.rec-item .info .name { font-size: 13px; font-weight: 600; }
.rec-item .info .meta { font-size: 11px; color: var(--text-secondary); display: flex; align-items: center; gap: 6px; margin-top: 2px; }
.rec-tag { font-size: 9px; padding: 1px 6px; border-radius: 4px; font-weight: 600; }
.rec-tag.recommend { background: rgba(0,181,120,0.15); color: var(--gain); }
.rec-tag.watch { background: rgba(250,173,20,0.15); color: var(--warn); }
.plan-item {
  background: var(--card-layer); border-radius: 8px; padding: 10px 12px;
  margin-bottom: 6px; font-size: 13px; line-height: 1.6;
}

/* ===== Prediction ===== */
.pred-card { margin-bottom: 12px; overflow: hidden; }
.pred-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px; cursor: pointer; transition: background 0.15s;
}
.pred-header:hover { background: var(--card-layer); }
.pred-header .fund-info { display: flex; flex-direction: column; gap: 2px; }
.pred-header .fund-info .name { font-size: 14px; font-weight: 600; }
.pred-header .fund-info .code { font-size: 11px; color: var(--text-secondary); }
.pred-header .dir-badge {
  font-size: 11px; font-weight: 600; padding: 3px 10px; border-radius: 6px;
}
.pred-header .dir-badge.up { background: rgba(0,181,120,0.15); color: var(--gain); }
.pred-header .dir-badge.down { background: rgba(255,77,79,0.15); color: var(--loss); }
.pred-header .dir-badge.sideways { background: rgba(250,173,20,0.15); color: var(--warn); }
.pred-body { padding: 0 14px 14px; }
.pred-days { display: flex; gap: 4px; margin-top: 8px; }
.pred-day {
  flex: 1; text-align: center; padding: 8px 4px; border-radius: 8px;
  background: var(--card-layer); font-size: 11px;
}
.pred-day .date { color: var(--text-secondary); margin-bottom: 4px; font-size: 10px; }
.pred-day .val { font-weight: 700; font-size: 13px; }
.pred-day .actual-line { color: var(--gain); font-size: 10px; margin-top: 2px; }
.pred-day .pred-line { color: var(--blue); font-size: 10px; margin-top: 2px; }
.pred-analysis { margin-top: 10px; padding: 10px; background: var(--card-layer); border-radius: 8px; font-size: 12px; line-height: 1.6; }
.pred-scores { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.pred-score { font-size: 11px; padding: 3px 8px; background: var(--card-layer); border-radius: 6px; }

/* ===== Profile ===== */
.profile-header {
  display: flex; align-items: center; gap: 14px; padding: 16px 0; margin-bottom: 14px;
}
.avatar {
  width: 52px; height: 52px; border-radius: 26px;
  background: var(--primary-grad); display: flex; align-items: center;
  justify-content: center; font-size: 22px; font-weight: 700; color: #fff;
  flex-shrink: 0;
}
.profile-info { flex: 1; }
.profile-info .phone { font-size: 16px; font-weight: 700; }
.profile-info .vip-badge {
  font-size: 10px; padding: 2px 8px; border-radius: 4px; font-weight: 700;
  background: rgba(212,175,55,0.15); color: var(--gold); display: inline-block; margin-top: 4px;
}
.menu-list { display: flex; flex-direction: column; gap: 1px; background: var(--card); border-radius: var(--radius-lg); overflow: hidden; margin-bottom: 14px; }
.menu-item {
  display: flex; align-items: center; gap: 12px; padding: 13px 16px;
  background: none; color: var(--text); font-size: 14px; width: 100%;
  text-align: left; transition: background 0.15s;
}
.menu-item:hover { background: var(--card-layer); }
.menu-item:active { background: rgba(255,255,255,0.05); }
.menu-item .menu-icon { font-size: 18px; width: 24px; text-align: center; flex-shrink: 0; }
.menu-item .menu-label { flex: 1; }
.menu-item .menu-arrow { color: var(--text-secondary); font-size: 12px; }
.menu-item .menu-extra { color: var(--text-secondary); font-size: 12px; margin-right: 4px; }

/* ===== Modal ===== */
.modal-overlay {
  position: fixed; inset: 0; z-index: 500;
  background: rgba(0,0,0,0.6); display: flex; align-items: center;
  justify-content: center; padding: 16px;
}
.modal-content {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 20px; width: 100%; max-width: 400px; max-height: 85vh; overflow-y: auto;
  animation: fadeIn 0.2s ease;
}
.modal-title { font-size: 16px; font-weight: 700; margin-bottom: 14px; }
.modal-close {
  background: none; color: var(--text-secondary); font-size: 13px;
  padding: 8px; width: 100%; text-align: center; margin-top: 12px;
  border-radius: var(--radius); transition: background 0.15s;
}
.modal-close:hover { background: var(--card-layer); }

/* ===== Fund Detail ===== */
.detail-nav-card {
  background: var(--primary-grad); border-radius: var(--radius-lg);
  padding: 18px; margin-bottom: 14px; position: relative;
}
.detail-nav-card::before {
  content: ''; position: absolute; top: -30px; right: -20px;
  width: 120px; height: 120px; border-radius: 50%;
  background: rgba(255,255,255,0.06);
}
.detail-nav-card .back-btn {
  background: rgba(255,255,255,0.15); border: none; color: #fff;
  width: 30px; height: 30px; border-radius: 8px; font-size: 16px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; margin-bottom: 10px;
}
.detail-nav-card .fund-code { font-size: 11px; opacity: 0.7; }
.detail-nav-card .nav-value { font-size: 32px; font-weight: 800; margin: 4px 0; }
.detail-nav-card .nav-change { font-size: 16px; font-weight: 600; }
.period-tabs { display: flex; gap: 4px; margin-bottom: 10px; }
.period-tab {
  flex: 1; padding: 6px; border-radius: 6px; font-size: 11px; font-weight: 600;
  background: var(--card-layer); color: var(--text-secondary); text-align: center;
  cursor: pointer; transition: all 0.2s;
}
.period-tab.active { background: var(--primary); color: #fff; }
.chart-container { background: var(--card); border-radius: var(--radius); padding: 14px; margin-bottom: 14px; }
.chart-container canvas { width: 100%; }
.ai-signal-card { background: var(--card); border-radius: var(--radius-lg); padding: 16px; margin-bottom: 14px; }
.ai-signal-card .signal-label { font-size: 12px; color: var(--text-secondary); margin-bottom: 6px; }
.ai-signal-card .signal-value { font-size: 18px; font-weight: 700; }
.rating-row { display: flex; gap: 6px; margin-top: 10px; flex-wrap: wrap; }
.rating-item { font-size: 11px; padding: 4px 8px; background: var(--card-layer); border-radius: 6px; }

/* ===== Search Input ===== */
.search-box {
  display: flex; align-items: center; gap: 8px;
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 8px 12px; margin-bottom: 10px;
}
.search-box input {
  flex: 1; background: none; color: var(--text); font-size: 13px; border: none;
}
.search-box input::placeholder { color: #555; }
.search-box .search-icon { font-size: 16px; color: var(--text-secondary); }

/* ===== Loading ===== */
.loading { text-align: center; padding: 30px; color: var(--text-secondary); font-size: 13px; }
.loading .spinner {
  width: 24px; height: 24px; border: 2px solid var(--border);
  border-top-color: var(--primary); border-radius: 50%;
  animation: spin 0.8s linear infinite; display: inline-block; margin-bottom: 8px;
}

/* ===== Responsive ===== */
@media (min-width: 640px) {
  .app-content { padding: 16px 24px 80px; }
  .fund-list { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
  .holding-list { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
}
