:root {
  --bf-blue: #06266f;
  --bf-blue-mid: #0a358f;
  --bf-blue-dark: #031842;
  --bf-gold: #f5a623;
  --bf-gold-light: #ffc14d;
  --bf-gold-grad: linear-gradient(135deg, #f5a623, #ffc14d);
  --bf-bg: #eef1f7;
  --bf-card: #ffffff;
  --bf-text: #16203d;
  --bf-muted: #7a8299;
  --bf-border: #e3e8f2;
  --bf-green: #0fae52;
  --bf-green-bg: #e7f8ee;
  --bf-red: #e0353e;
  --bf-red-bg: #fdecee;
  --shadow-sm: 0 1px 3px rgba(16, 34, 77, 0.08);
  --shadow-md: 0 4px 16px rgba(16, 34, 77, 0.10);
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--bf-bg);
  color: var(--bf-text);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

/* ---- 顶部导航 ---- */
.navbar {
  background: linear-gradient(135deg, var(--bf-blue-dark), var(--bf-blue) 55%, var(--bf-blue-mid));
  color: #fff;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  box-shadow: 0 2px 12px rgba(3, 24, 66, 0.3);
  position: sticky;
  top: 0;
  z-index: 100;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand .logo { display: flex; align-items: center; }
.brand .name { font-size: 17px; font-weight: 700; letter-spacing: 0.3px; }
.brand .name small { display: block; font-size: 10px; font-weight: 400; color: #9fb0d8; letter-spacing: 0.5px; }
.links { display: flex; align-items: center; gap: 6px; }
.links a {
  color: #b9c5e6; text-decoration: none; font-size: 14px;
  padding: 7px 16px; border-radius: 8px; transition: all 0.15s;
}
.links a:hover { color: #fff; background: rgba(255,255,255,0.08); }
.links a.active { color: var(--bf-gold); font-weight: 600; background: rgba(245,166,35,0.12); }
.live-dot { display: flex; align-items: center; gap: 6px; font-size: 12px; color: #9fb0d8; margin-left: 10px; }
.live-dot .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--bf-green); box-shadow: 0 0 0 3px rgba(15,174,82,0.25); animation: pulse 2s infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.5; } }

.container { max-width: 1280px; margin: 24px auto; padding: 0 24px; }

/* ---- Hero 大屏 ---- */
.hero {
  display: grid;
  grid-template-columns: 1.6fr 1fr;
  gap: 18px;
  margin-bottom: 20px;
}
.hero-main {
  background: linear-gradient(135deg, var(--bf-blue-dark), var(--bf-blue));
  color: #fff; border-radius: 16px; padding: 26px 30px;
  box-shadow: var(--shadow-md); position: relative; overflow: hidden;
}
.hero-main::after {
  content: ''; position: absolute; right: -60px; top: -60px; width: 220px; height: 220px;
  background: radial-gradient(circle, rgba(245,166,35,0.25), transparent 70%);
}
.hero-label { font-size: 13px; color: #9fb0d8; letter-spacing: 1px; }
.hero-value { font-size: 44px; font-weight: 800; margin: 6px 0 2px; font-variant-numeric: tabular-nums; }
.hero-value.up { color: #5be28a; }
.hero-value.down { color: #ff7b84; }
.hero-sub { font-size: 13px; color: #b9c5e6; }

.hero-side {
  background: var(--bf-card); border-radius: 16px; padding: 22px 26px;
  box-shadow: var(--shadow-md); display: flex; flex-direction: column; justify-content: center; gap: 14px;
}
.hero-side .row { display: flex; justify-content: space-between; align-items: center; }
.hero-side .row .k { color: var(--bf-muted); font-size: 13px; }
.hero-side .row .v { font-size: 17px; font-weight: 700; font-variant-numeric: tabular-nums; }

/* ---- 卡片 ---- */
.card {
  background: var(--bf-card); border: 1px solid var(--bf-border);
  border-radius: 14px; padding: 20px; box-shadow: var(--shadow-sm);
}
.card h2 {
  font-size: 14px; color: var(--bf-blue); margin-bottom: 14px; font-weight: 700;
  display: flex; align-items: center; gap: 8px;
}
.card h2::before { content: ''; width: 4px; height: 16px; background: var(--bf-gold-grad); border-radius: 2px; }

.grid { display: grid; gap: 18px; }
.grid-stats { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(500px, 1fr)); }

.stat { text-align: center; padding: 16px 12px; }
.stat .num { font-size: 26px; font-weight: 800; font-variant-numeric: tabular-nums; }
.stat .num.green { color: var(--bf-green); }
.stat .num.red { color: var(--bf-red); }
.stat .num.gold { color: var(--bf-gold); }
.stat .label { font-size: 12px; color: var(--bf-muted); margin-top: 6px; }

/* ---- 曲线图 ---- */
.chart-wrap { width: 100%; height: 220px; position: relative; }
.chart-wrap canvas { width: 100%; height: 100%; display: block; }

/* ---- 表格 ---- */
table { width: 100%; border-collapse: collapse; }
th, td { padding: 9px 8px; text-align: left; border-bottom: 1px solid var(--bf-border); font-size: 12px; white-space: nowrap; }
th { color: var(--bf-muted); font-weight: 600; font-size: 11px; background: #f8fafd; }
tbody tr:hover { background: #f6f8fc; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
img, svg, canvas { max-width: 100%; }

.badge { display: inline-block; padding: 3px 9px; border-radius: 5px; font-size: 12px; font-weight: 600; }
.badge.long { background: var(--bf-green-bg); color: var(--bf-green); }
.badge.short { background: var(--bf-red-bg); color: var(--bf-red); }
.badge.none { background: #eef1f7; color: var(--bf-muted); }
.badge.scheduled { background: #fff5e0; color: #b7791f; }
.badge.completed { background: var(--bf-green-bg); color: var(--bf-green); }

.pnl-up { color: var(--bf-green); font-weight: 700; }
.pnl-down { color: var(--bf-red); font-weight: 700; }

/* ---- Tab ---- */
.tabs { display: flex; gap: 4px; background: #eef1f7; padding: 4px; border-radius: 10px; margin-bottom: 14px; }
.tabs button {
  flex: 1; border: none; background: transparent; padding: 8px 12px;
  border-radius: 7px; font-size: 13px; cursor: pointer; color: var(--bf-muted);
  transition: all 0.15s;
}
.tabs button.active { background: #fff; color: var(--bf-blue); font-weight: 700; box-shadow: var(--shadow-sm); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ---- 登录 ---- */
.login-box { max-width: 380px; margin: 40px auto 0; padding: 28px; }
.login-box .logo-big { text-align: center; margin-bottom: 20px; }
.login-box input {
  width: 100%; padding: 11px 14px; margin: 8px 0 16px;
  border: 1px solid var(--bf-border); border-radius: 8px; font-size: 16px;
}
.login-box input:focus { outline: none; border-color: var(--bf-blue); box-shadow: 0 0 0 3px rgba(6,38,111,0.1); }

/* ---- 表单/按钮 ---- */
.form-row { margin-bottom: 14px; }
.form-row label { display: block; font-size: 12px; color: var(--bf-muted); margin-bottom: 5px; }
.form-row input {
  width: 100%; padding: 10px 12px; border: 1px solid var(--bf-border); border-radius: 8px; font-size: 16px;
}
.form-row input:focus { outline: none; border-color: var(--bf-blue); }

.btn {
  display: inline-block; background: var(--bf-gold-grad); color: #fff;
  border: none; padding: 10px 22px; border-radius: 8px;
  font-size: 14px; font-weight: 700; cursor: pointer; text-decoration: none;
  box-shadow: 0 3px 10px rgba(245,166,35,0.35); transition: transform 0.1s, box-shadow 0.15s;
}
.btn:hover { transform: translateY(-1px); box-shadow: 0 5px 16px rgba(245,166,35,0.45); }
.btn.blue { background: linear-gradient(135deg, var(--bf-blue), var(--bf-blue-mid)); box-shadow: 0 3px 10px rgba(6,38,111,0.3); }

.toast {
  position: fixed; bottom: 24px; right: 24px; background: var(--bf-blue);
  color: #fff; padding: 13px 22px; border-radius: 10px; display: none;
  box-shadow: var(--shadow-md); z-index: 200;
}

@media (max-width: 900px) {
  .hero { grid-template-columns: 1fr; }
  .grid-2 { grid-template-columns: 1fr; }
  .hero-value { font-size: 34px; }
  .container { padding: 0 14px; margin: 14px auto; }
  .navbar { padding: 0 14px; height: 54px; }
  .brand .name small { display: none; }
  .links a { padding: 6px 10px; font-size: 13px; }
  .tab-panel { overflow-x: auto; }
  table { min-width: 500px; }
  .stat .num { font-size: 22px; }
  .hero-main { padding: 20px; }
  .hero-side { padding: 16px 18px; }
}

/* ================= App 布局 ================= */
html, body { height: 100%; width: 100%; overflow: hidden; max-width: 100%; }

.app-shell {
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bf-bg);
}
@media (min-width: 768px) {
  .app-shell {
    left: 50%;
    right: auto;
    transform: translateX(-50%);
    width: min(1080px, 100vw);
    box-shadow: 0 0 30px rgba(3,24,66,0.12);
  }
}

/* 桌面端：内容区更宽，表格完整展示 */
@media (min-width: 768px) {
  .app-content { padding: 20px 28px; }
  .market-card { display: inline-block; width: calc(50% - 8px); margin: 0 12px 12px 0; vertical-align: top; }
  .markets-grid { display: flex; flex-wrap: wrap; }
}

.app-header {
  flex-shrink: 0;
  height: calc(54px + env(safe-area-inset-top, 0px));
  padding: env(safe-area-inset-top, 0px) 16px 0;
  background: linear-gradient(135deg, var(--bf-blue-dark), var(--bf-blue) 55%, var(--bf-blue-mid));
  color: #fff; display: flex; align-items: center; justify-content: space-between;
  z-index: 50;
}
.app-header .brand { display: flex; align-items: center; gap: 9px; }
.app-header .name { font-size: 16px; font-weight: 700; }
.app-header .live-dot { display: flex; align-items: center; gap: 6px; font-size: 12px; color: #b9c5e6; }
.app-header .live-dot .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--bf-green); box-shadow: 0 0 0 3px rgba(15,174,82,0.25); animation: pulse 2s infinite; }
.header-right { display: flex; align-items: center; gap: 12px; }
.lang-switch { position: relative; }
.lang-btn {
  color: #b9c5e6; background: transparent; border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  padding: 7px 8px; border-radius: 6px; transition: all 0.15s;
}
.lang-btn:hover { color: #fff; background: rgba(255,255,255,0.1); }
.lang-menu {
  position: absolute; top: 36px; right: 0; background: #fff; border-radius: 8px;
  box-shadow: 0 6px 20px rgba(3,24,66,0.2); overflow: hidden; display: none; z-index: 200;
  min-width: 120px;
}
.lang-menu button {
  display: block; width: 100%; padding: 10px 16px; border: none; background: none;
  text-align: left; font-size: 13px; color: var(--bf-text); cursor: pointer;
}
.lang-menu button:hover { background: #f4f6fb; color: var(--bf-blue); }

.app-content { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 14px; background: var(--bf-bg); -webkit-overflow-scrolling: touch; min-height: 0; }
.tab { display: none; }
.tab.active { display: block; }

/* 电脑端：隐藏底部导航，所有内容多列平铺 */
@media (min-width: 768px) {
  .bottom-nav { display: none; }
  .app-content { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-content: start; padding: 20px 24px; }
  .tab { display: block !important; }
  #tab-markets, #tab-performance, #tab-chart { grid-column: 1 / -1; }
}

.bottom-nav {
  flex-shrink: 0; display: flex;
  background: rgba(255,255,255,0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: none;
  height: calc(56px + env(safe-area-inset-bottom, 0px));
  padding-bottom: env(safe-area-inset-bottom, 0px);
  z-index: 50;
}
.bottom-nav button {
  flex: 1; border: none; background: transparent; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  font-size: 10px; color: var(--bf-muted); transition: color 0.15s;
  padding: 6px 0 4px;
}
.bottom-nav button svg { display: block; transition: transform 0.15s; }
.bottom-nav button.active { color: var(--bf-blue); font-weight: 700; }
.bottom-nav button.active svg { transform: scale(1.05); }

/* 交易标的卡片 */
.market-card {
  background: var(--bf-card); border: 1px solid var(--bf-border);
  border-radius: 14px; padding: 18px; margin-bottom: 12px; box-shadow: var(--shadow-sm);
}
.m-top { display: flex; justify-content: space-between; align-items: center; }
.m-symbol { font-size: 17px; font-weight: 800; color: var(--bf-blue); }
.m-symbol span { font-size: 12px; color: var(--bf-muted); font-weight: 500; }
.m-price { font-size: 30px; font-weight: 800; margin: 8px 0 6px; font-variant-numeric: tabular-nums; }
.m-bottom { display: flex; justify-content: space-between; font-size: 12px; color: var(--bf-muted); padding-top: 8px; border-top: 1px dashed var(--bf-border); }

/* 盈亏大屏 */
.perf-hero {
  background: linear-gradient(135deg, var(--bf-blue-dark), var(--bf-blue));
  color: #fff; border-radius: 16px; padding: 24px; text-align: center;
  margin-bottom: 14px; box-shadow: var(--shadow-md); position: relative; overflow: hidden;
}
.perf-hero::after { content:''; position:absolute; right:-50px; top:-50px; width:180px; height:180px; background: radial-gradient(circle, rgba(245,166,35,0.22), transparent 70%); }
.perf-label { font-size: 13px; color: #9fb0d8; letter-spacing: 1px; }
.perf-value { font-size: 42px; font-weight: 800; margin: 6px 0; font-variant-numeric: tabular-nums; }
.perf-sub { font-size: 13px; color: #b9c5e6; }

/* 我的页面 */
.me-row { display: flex; justify-content: space-between; align-items: center; padding: 11px 0; border-bottom: 1px solid var(--bf-border); font-size: 14px; }
.me-row:last-child { border-bottom: none; }
.me-row span { color: var(--bf-muted); }
.me-row b { font-weight: 700; font-variant-numeric: tabular-nums; }

.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--bf-border);
  border-radius: 8px;
}
.table-wrap table { width: 100%; min-width: max-content; }
.table-wrap thead th { position: sticky; top: 0; z-index: 2; }

/* ---- K线详情 ---- */
.chart-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.back-btn { background: none; border: none; color: var(--bf-blue); font-size: 15px; font-weight: 600; cursor: pointer; padding: 4px 0; }
.chart-title { font-size: 16px; font-weight: 800; color: var(--bf-blue); }
.chart-price { font-size: 14px; font-weight: 700; }

.tf-btns { display: flex; gap: 6px; margin-bottom: 10px; }
.tf-btns button {
  flex: 1; border: 1px solid var(--bf-border); background: #fff; color: var(--bf-muted);
  padding: 6px 0; border-radius: 6px; font-size: 12px; cursor: pointer;
}
.tf-btns button.active { background: var(--bf-blue); color: #fff; border-color: var(--bf-blue); font-weight: 600; }

.kline-wrap { width: 100%; height: 360px; }
.kline-wrap canvas { width: 100%; height: 100%; display: block; }

.back-link { color: #cbd5f0; text-decoration: none; font-size: 14px; font-weight: 600; }
.back-link:active { opacity: 0.7; }

/* ================= 电脑版布局（成熟后台模板） ================= */
body.web-page { height: 100vh; overflow: hidden; }
.desktop-layout { display: flex; height: 100vh; width: 100%; }
.sidebar {
  width: 220px; flex-shrink: 0;
  background: linear-gradient(180deg, #031842, #06266f 70%, #0a358f);
  color: #fff; display: flex; flex-direction: column;
}
.sidebar-brand { padding: 20px 18px; display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 16px; border-bottom: 1px solid rgba(255,255,255,0.08); }
.sidebar-nav { flex: 1; padding: 14px 10px; overflow-y: auto; }
.sidebar-nav a {
  display: flex; align-items: center; gap: 11px; padding: 11px 14px;
  color: #aebbe0; text-decoration: none; border-radius: 9px; margin-bottom: 3px;
  font-size: 14px; cursor: pointer; transition: all 0.15s;
}
.sidebar-nav a svg { flex-shrink: 0; }
.sidebar-nav a:hover { background: rgba(255,255,255,0.08); color: #fff; }
.sidebar-nav a.active { background: var(--bf-gold); color: #fff; font-weight: 700; box-shadow: 0 3px 10px rgba(245,166,35,0.3); }
.desktop-main { flex: 1; display: flex; flex-direction: column; overflow: hidden; background: var(--bf-bg); }
.desktop-header {
  height: 60px; flex-shrink: 0; display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px; background: #fff; border-bottom: 1px solid var(--bf-border);
}
.desktop-header h1 { font-size: 19px; color: var(--bf-blue); font-weight: 700; }
.desktop-header .right { display: flex; align-items: center; gap: 16px; }
.desktop-header .right .live-dot { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--bf-muted); }
.desktop-header .right .live-dot .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--bf-green); box-shadow: 0 0 0 3px rgba(15,174,82,0.25); animation: pulse 2s infinite; }
.desktop-content { flex: 1; overflow-y: auto; padding: 22px 24px; }
.view { display: none; }
.view.active { display: block; }
.view h2.page-title { font-size: 16px; color: var(--bf-blue); margin-bottom: 16px; }

.exp-select { width: 100%; padding: 10px 12px; border: 1px solid var(--bf-border); border-radius: 8px; font-size: 16px; background: #fff; }
