/* ============ 主题变量 ============ */
:root {
  --bg: #ffffff;
  --bg-soft: #f8f9fd;
  --panel: #ffffff;
  --panel-hover: #f3f4f7;
  --border: #e7e8ed;
  --border-soft: #eff0f3;
  --text: #131722;
  --muted: #868a95;
  --accent: #2962ff;
  --accent-soft: rgba(41, 98, 255, 0.1);
  /* 中性"已激活"底色：外壳按钮不用蓝，只有真正的内容选中才用强调色 */
  --active-bg: #eceef2;
  --up: #089981;
  --down: #f23645;
  --up-soft: rgba(8, 153, 129, 0.1);
  --down-soft: rgba(242, 54, 69, 0.1);
  --shadow: 0 6px 24px rgba(19, 23, 34, 0.1);
  --chip-bg: #f0f1f4;
  --overlay: rgba(19, 23, 34, 0.32);
  --star: #f0a92b;
  --radius-sm: 4px;
  --radius: 6px;
  --radius-lg: 10px;
  --ease: 130ms cubic-bezier(0.4, 0, 0.2, 1);
  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #0f0f0f;
  --bg-soft: #141414;
  --panel: #171717;
  --panel-hover: #222222;
  --border: #2a2a2a;
  --border-soft: #202020;
  --text: #d1d4dc;
  --muted: #787b86;
  --accent: #2962ff;
  --accent-soft: rgba(41, 98, 255, 0.2);
  --active-bg: #292929;
  --up: #089981;
  --down: #f23645;
  --shadow: 0 6px 24px rgba(0, 0, 0, 0.5);
  --chip-bg: #242424;
  --overlay: rgba(0, 0, 0, 0.55);
  --star: #f0a92b;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  /* 系统 UI 字体：Windows 走 Segoe UI + 雅黑，数字观感立刻现代 */
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Microsoft YaHei UI", "Microsoft YaHei", "PingFang SC", sans-serif;
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a { color: inherit; text-decoration: none; }
button {
  font-family: inherit;
  color: inherit;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 14px;
  transition: background-color var(--ease), color var(--ease), border-color var(--ease);
}
input, select {
  font-family: inherit;
  color: var(--text);
}

.num { font-variant-numeric: tabular-nums; }
.up { color: var(--up) !important; }
.down { color: var(--down) !important; }
.flat { color: var(--muted) !important; }
.hidden { display: none !important; }

/* 统一微交互过渡：让 hover / 选中有 TV 那种"活着"的顺滑感 */
.watch-row, .item-row, .restock-row, .sym-row, .ind-row,
.tb-menu .menu-row, .rail-btn, .icon-btn, .chip, .modal-close,
.main-nav a, .lg-ind-row, .star-btn, .a-del {
  transition: background-color var(--ease), color var(--ease), border-color var(--ease);
}

/* SVG 图标在各类容器里都居中成块 */
.icon-btn svg, .modal-close svg, .star svg, .star-btn svg,
.a-del svg, .sp-head svg, [data-act] svg,
.search-icon svg, .ind-nav button svg { display: block; }
.i-added svg { display: inline-block; vertical-align: -2px; }
/* 收藏后的星填成实心，一眼可辨 */
.star.faved svg, .star-btn.faved svg { fill: var(--star); }

/* ============ 顶栏（首页） ============ */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 14px;
  height: 52px;
  padding: 0 16px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 16px;
  white-space: nowrap;
}
.brand .brand-mark {
  width: 26px;
  height: 26px;
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  font-weight: 800;
}

.main-nav { display: flex; align-items: center; gap: 4px; }
.main-nav a {
  padding: 6px 12px;
  border-radius: 8px;
  color: var(--muted);
  font-weight: 500;
  white-space: nowrap;
}
.main-nav a:hover { background: var(--panel-hover); color: var(--text); }
.main-nav a.active { color: var(--text); font-weight: 600; }

.header-spacer { flex: 1; }

.search-box { position: relative; width: 260px; }
.search-box input {
  width: 100%;
  height: 34px;
  padding: 0 12px 0 34px;
  border: 1px solid var(--border);
  border-radius: 17px;
  background: var(--bg-soft);
  color: var(--text);
  font-size: 13px;
  outline: none;
}
.search-box input:focus { border-color: var(--accent); background: var(--bg); }
.search-box .search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  pointer-events: none;
}
.search-results {
  position: absolute;
  top: 40px;
  left: 0;
  right: 0;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow);
  overflow: hidden;
  display: none;
}
.search-results.open { display: block; }
.search-results button {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 12px;
  text-align: left;
}
.search-results button:hover, .search-results button.hl { background: var(--panel-hover); }

.header-clock { color: var(--muted); font-size: 12px; white-space: nowrap; }

.icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 6px;
  color: var(--muted);
  flex: none;
}
.icon-btn:hover { background: var(--panel-hover); color: var(--text); }
.icon-btn.active { background: var(--accent-soft); color: var(--accent); }

/* ============ 符号图标 ============ */
.sym-icon {
  flex: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.2px;
}
.sym-icon.sm { width: 18px; height: 18px; font-size: 9px; }
.sym-icon.lg { width: 40px; height: 40px; font-size: 18px; }
.sym-icon.sym-icon-image {
  position: relative;
  border-radius: 4px;
  overflow: hidden;
}
.sym-icon.sym-icon-image img {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: var(--bg);
}

/* ============ 首页布局 ============ */
.home-main {
  max-width: 1480px;
  margin: 0 auto;
  padding: 20px 16px 60px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 20px;
  align-items: start;
}
@media (max-width: 1024px) {
  .home-main { grid-template-columns: 1fr; }
}

.home-title {
  font-size: 26px;
  font-weight: 700;
  margin: 6px 0 16px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.home-title a:hover { color: var(--accent); }

.hero-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 20px 8px;
  background: var(--panel);
}
.hero-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.hero-name {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 17px;
  font-weight: 700;
  cursor: pointer;
}
.hero-name:hover { color: var(--accent); }
.hero-code {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 5px;
  background: var(--chip-bg);
  color: var(--muted);
  font-weight: 600;
}
.hero-price-row { display: flex; align-items: baseline; gap: 12px; margin: 8px 0 4px; }
.hero-price { font-size: 34px; font-weight: 800; letter-spacing: -0.5px; }
.hero-change { font-size: 15px; font-weight: 600; }
.hero-meta { color: var(--muted); font-size: 12px; }
.hero-chart { height: 340px; position: relative; }
.hero-ranges { display: flex; gap: 4px; padding: 8px 0 10px; border-top: 1px solid var(--border-soft); }
.hero-ranges button {
  padding: 5px 12px;
  border-radius: 8px;
  color: var(--muted);
  font-weight: 500;
}
.hero-ranges button:hover { background: var(--panel-hover); color: var(--text); }
.hero-ranges button.active { background: var(--active-bg); color: var(--text); font-weight: 600; }

.cards-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-top: 20px;
}
@media (max-width: 860px) { .cards-row { grid-template-columns: 1fr; } }
.info-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--panel);
  padding: 14px 16px;
  min-width: 0;
}
.info-card h3 { margin: 2px 0 10px; font-size: 16px; }
.item-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 8px;
  border-radius: 10px;
  cursor: pointer;
}
.item-row:hover { background: var(--panel-hover); }
.item-row .item-name { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.item-row .item-name strong { font-size: 13px; }
.item-row .item-name span { font-size: 11px; color: var(--muted); }
.item-row .item-spark { flex: none; }
.item-row .item-quote {
  flex: none;
  text-align: right;
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 84px;
}
.item-row .item-quote strong { font-size: 13px; }
.item-row .item-quote span { font-size: 12px; font-weight: 600; }

.restock-row { display: flex; align-items: center; gap: 10px; padding: 9px 8px; border-radius: 10px; }
.restock-row:hover { background: var(--panel-hover); }
.restock-row .r-main { flex: 1; min-width: 0; }
.restock-row .r-main strong { font-size: 13px; }
.restock-row .r-main span { display: block; font-size: 11px; color: var(--muted); margin-top: 1px; }
.restock-row .r-price { font-weight: 700; color: var(--down); }
.empty-hint { color: var(--muted); font-size: 12px; padding: 12px 8px; }

/* ============ Watchlist 面板（两页共用） ============ */
.watch-panel {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--panel);
  overflow: hidden;
  position: sticky;
  top: 68px;
}
.watch-panel .wp-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px 8px;
  font-weight: 700;
  font-size: 15px;
}
.watch-section {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 6px 14px 2px;
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.4px;
  cursor: pointer;
  user-select: none;
}
.watch-section .caret { font-size: 9px; transition: transform 0.12s; }
.watch-section.collapsed .caret { transform: rotate(-90deg); }
.watch-cols {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 76px 82px;
  padding: 4px 14px;
  font-size: 11px;
  color: var(--muted);
  border-bottom: 1px solid var(--border-soft);
}
.watch-cols span:nth-child(n+2) { text-align: right; }
.watch-rows { max-height: 420px; overflow-y: auto; }
.watch-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 76px 82px;
  align-items: center;
  padding: 7px 14px;
  cursor: pointer;
  border-left: 2px solid transparent;
}
.watch-row:hover { background: var(--panel-hover); }
.watch-row.selected { background: var(--accent-soft); border-left-color: var(--accent); }
.watch-row .w-sym {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  font-weight: 600;
  font-size: 14px;
  overflow: hidden;
  white-space: nowrap;
}
.watch-row .w-sym > span:last-child {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.watch-row .w-sym .sym-icon { width: 20px; height: 20px; font-size: 10px; }
.watch-row .w-price, .watch-row .w-chg { text-align: right; font-size: 13.5px; font-weight: 600; }
.watch-row .w-chg { display: flex; flex-direction: column; align-items: flex-end; line-height: 1.25; }
.watch-row .w-chg small { font-weight: 500; }
@keyframes flash-up { 0% { background: var(--up-soft); } 100% { background: transparent; } }
@keyframes flash-down { 0% { background: var(--down-soft); } 100% { background: transparent; } }
.watch-row.flash-up { animation: flash-up 0.9s ease-out; }
.watch-row.flash-down { animation: flash-down 0.9s ease-out; }

.detail-card { border-top: 1px solid var(--border); padding: 14px; }
.detail-card .d-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.detail-card .d-head .d-names { min-width: 0; }
.detail-card .d-head strong { font-size: 15px; display: block; }
.detail-card .d-head span { font-size: 11px; color: var(--muted); }
.detail-price-row { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.detail-price { font-size: 26px; font-weight: 800; }
.detail-change { font-size: 13px; font-weight: 600; }
.detail-sub { color: var(--muted); font-size: 11px; margin-top: 2px; }
.market-status {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  color: var(--up);
  font-weight: 600;
  margin-top: 6px;
}
.market-status .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--up);
}
.market-status.stale { color: var(--muted); }
.market-status.stale .dot { background: var(--muted); }
.detail-stats {
  margin-top: 10px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 12px;
  font-size: 12px;
}
.detail-stats div { display: flex; flex-direction: column; gap: 1px; }
.detail-stats span { color: var(--muted); font-size: 11px; }
.detail-stats strong { font-weight: 600; }

/* ============ 图表页骨架 ============ */
.chart-app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

/* --- 顶部工具栏：TV 紧凑风 --- */
.chart-toolbar {
  display: flex;
  align-items: center;
  gap: 2px;
  min-height: 44px;
  padding: 3px 6px;
  border-bottom: 1px solid var(--border);
  flex: none;
  flex-wrap: wrap; /* 窄屏换行；不能用 overflow 滚动，会裁掉下拉菜单 */
  position: relative;
  z-index: 40;
}
.tb-sep { width: 1px; height: 20px; background: var(--border); margin: 0 5px; flex: none; }
.tb-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  height: 32px;
  padding: 0 9px;
  border-radius: 6px;
  color: var(--text);
  font-weight: 500;
  white-space: nowrap;
  font-size: 14px;
}
.tb-btn:hover { background: var(--panel-hover); }
.tb-btn.active { background: var(--active-bg); color: var(--text); font-weight: 600; }
.tb-btn.symbol-btn { font-weight: 700; font-size: 15px; padding: 0 10px 0 6px; }
.tb-btn svg { flex: none; }
.tb-btn .caret { color: var(--muted); margin-left: 0; display: inline-flex; }
.tb-btn .caret svg { display: block; }
.tf-current { display: none; }
.tb-btn:disabled { opacity: 0.4; cursor: default; }
.mobile-fullscreen-btn { display: none; }

.tb-dropdown { position: relative; }
.tb-menu {
  position: absolute;
  top: 36px;
  left: 0;
  z-index: 80;
  min-width: 200px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 4px;
  display: none;
  max-height: min(560px, calc(100vh - 120px));
  overflow-y: auto;
}
.tb-menu.open { display: block; }
.tb-menu.align-right { left: auto; right: 0; }
.tb-menu .menu-title {
  font-size: 11px;
  color: var(--muted);
  padding: 8px 10px 3px;
  letter-spacing: 0.4px;
  position: sticky;
  top: 0;
  background: var(--panel);
}
.tb-menu .menu-row, .tb-menu > button {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 7px 10px;
  border-radius: 6px;
  text-align: left;
  font-size: 13px;
  cursor: pointer;
}
.tb-menu .menu-row:hover, .tb-menu > button:hover { background: var(--panel-hover); }
.tb-menu .menu-row.checked { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.tb-menu .menu-row .row-label { flex: 1; }
.tb-menu .menu-row .star {
  flex: none;
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 5px;
  color: transparent;
  font-size: 13px;
}
.tb-menu .menu-row:hover .star { color: var(--muted); }
.tb-menu .menu-row .star.faved { color: var(--star) !important; }
.tb-menu .menu-row .star:hover { background: var(--chip-bg); color: var(--star); }

.custom-period {
  display: flex;
  gap: 6px;
  align-items: center;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border-soft);
  margin-bottom: 2px;
}
.custom-period input {
  width: 56px;
  height: 28px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  padding: 0 8px;
  outline: none;
  font-size: 13px;
}
.custom-period input:focus { border-color: var(--accent); }
.custom-period select {
  height: 28px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  outline: none;
  font-size: 13px;
}
.custom-period .add-btn {
  height: 28px;
  padding: 0 10px;
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
}

/* --- 模态弹窗（商品搜索 / 指标库） --- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: var(--overlay);
  z-index: 100;
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding: 60px 16px 40px;
}
.modal-overlay.open { display: flex; }
.modal {
  width: 720px;
  max-width: 100%;
  max-height: calc(100vh - 120px);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px 10px;
}
.modal-head h2 { margin: 0; font-size: 19px; }
.modal-close {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  color: var(--muted);
  font-size: 18px;
}
.modal-close:hover { background: var(--panel-hover); color: var(--text); }
.modal-search { padding: 0 20px 12px; }
.modal-search input {
  width: 100%;
  height: 38px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  padding: 0 12px 0 36px;
  font-size: 14px;
  outline: none;
}
.modal-search { position: relative; }
.modal-search .search-icon {
  position: absolute;
  left: 32px;
  top: 10px;
  color: var(--muted);
  pointer-events: none;
}
.modal-search input:focus { border-color: var(--accent); }
.modal-chips { display: flex; gap: 6px; padding: 0 20px 12px; flex-wrap: wrap; }
.chip {
  height: 28px;
  padding: 0 12px;
  border-radius: 14px;
  background: var(--chip-bg);
  color: var(--text);
  font-size: 12.5px;
  font-weight: 500;
}
.chip:hover { background: var(--panel-hover); }
.chip.active { background: var(--text); color: var(--bg); font-weight: 600; }
.modal-body { flex: 1; min-height: 200px; overflow-y: auto; border-top: 1px solid var(--border-soft); }

/* 商品搜索行 */
.sym-row {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 20px;
  cursor: pointer;
  text-align: left;
}
.sym-row:hover { background: var(--panel-hover); }
.sym-row .star-btn {
  flex: none;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 5px;
  color: transparent;
  font-size: 14px;
}
.sym-row:hover .star-btn { color: var(--muted); }
.sym-row .star-btn.faved { color: var(--star) !important; }
.sym-row .star-btn:hover { background: var(--chip-bg); color: var(--star); }
.sym-row .s-code { font-weight: 700; min-width: 90px; }
.sym-row .s-name { flex: 1; color: var(--muted); font-size: 13px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sym-row .s-type { color: var(--muted); font-size: 11.5px; white-space: nowrap; }
.sym-row .s-exch { font-size: 11.5px; font-weight: 600; white-space: nowrap; }

/* 指标库 */
.ind-layout { display: flex; min-height: 0; flex: 1; }
.ind-nav {
  flex: none;
  width: 168px;
  border-right: 1px solid var(--border-soft);
  padding: 10px 8px;
  overflow-y: auto;
}
.ind-nav .nav-title { font-size: 11px; color: var(--muted); padding: 8px 8px 3px; }
.ind-nav button {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 10px;
  border-radius: 6px;
  text-align: left;
  font-size: 13px;
}
.ind-nav button:hover { background: var(--panel-hover); }
.ind-nav button.active { background: var(--chip-bg); font-weight: 600; }
.ind-list { flex: 1; overflow-y: auto; padding: 6px 0; }
.ind-row {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 20px 8px 14px;
  cursor: pointer;
  text-align: left;
  font-size: 13.5px;
}
.ind-row:hover { background: var(--panel-hover); }
.ind-row .star-btn {
  flex: none;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 5px;
  color: transparent;
  font-size: 14px;
}
.ind-row:hover .star-btn { color: var(--muted); }
.ind-row .star-btn.faved { color: var(--star) !important; }
.ind-row .i-name { flex: 1; }
.ind-row .i-name small { color: var(--muted); font-size: 11.5px; margin-left: 6px; }
.ind-row .i-added {
  color: var(--accent);
  font-size: 12px;
  font-weight: 600;
  visibility: hidden;
}
.ind-row.added .i-added { visibility: visible; }

/* 指标小条打开的二级周期设置 */
.indicator-settings-modal { width: 430px; min-height: 360px; }
.indicator-settings-tabs {
  display: flex;
  gap: 22px;
  padding: 0 20px;
  border-bottom: 1px solid var(--border-soft);
}
.indicator-settings-tabs button {
  position: relative;
  padding: 9px 0 10px;
  font-weight: 600;
}
.indicator-settings-tabs button:disabled { color: var(--muted); cursor: default; }
.indicator-settings-tabs button.active::after {
  content: "";
  position: absolute;
  right: 0;
  bottom: -1px;
  left: 0;
  height: 3px;
  border-radius: 3px 3px 0 0;
  background: var(--text);
}
.indicator-settings-fields { flex: 1; padding: 16px 20px; overflow-y: auto; }
.ind-param-row {
  display: flex;
  align-items: center;
  gap: 16px;
  min-height: 46px;
  font-size: 13px;
}
.ind-param-row > span:first-child { flex: 1; }
.ind-param-input { display: flex; align-items: center; gap: 6px; }
.ind-param-input input {
  width: 148px;
  height: 34px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  padding: 0 10px;
  outline: none;
}
.ind-param-input input:focus { border-color: var(--accent); }
.ind-param-input em { min-width: 16px; color: var(--muted); font-style: normal; }
.indicator-settings-actions { display: flex; align-items: center; gap: 8px; }

/* --- 图表主体 --- */
.chart-body { flex: 1; display: flex; min-height: 0; }

/* 左侧画线工具栏 */
.draw-rail {
  flex: none;
  width: 44px;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 6px 0;
}
.draw-rail .rail-btn {
  width: 34px;
  height: 34px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
}
.draw-rail .rail-btn:hover { background: var(--panel-hover); color: var(--text); }
.draw-rail .rail-btn.active { background: var(--accent-soft); color: var(--accent); }
.draw-rail .rail-sep { width: 24px; height: 1px; background: var(--border); margin: 4px 0; }

.chart-stage {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  position: relative;
}
.chart-host { flex: 1; min-height: 0; position: relative; }
#tvchart { position: absolute; inset: 0; }
#tvchart.tool-armed { cursor: crosshair; }

/* 图例 */
.chart-legend {
  position: absolute;
  top: 6px;
  left: 8px;
  z-index: 20;
  font-size: 14px;
  line-height: 1.5;
  pointer-events: none;
  max-width: calc(100% - 90px);
}
.chart-legend .lg-line1 {
  font-weight: 600;
  font-size: 15px;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  text-shadow: 0 0 4px var(--bg);
}
.chart-legend .lg-vals { display: inline-flex; align-items: center; gap: 8px; font-weight: 400; text-shadow: 0 0 4px var(--bg); }
.chart-legend .lg-vals span { margin-right: 0; white-space: nowrap; }
.chart-legend .legend-symbol { width: 20px; height: 20px; font-size: 11px; }
.lg-ind-row {
  display: flex;
  align-items: center;
  gap: 4px;
  pointer-events: auto;
  width: fit-content;
  padding: 1px 4px 1px 0;
  border-radius: 5px;
  text-shadow: 0 0 4px var(--bg);
}
.lg-ind-row:hover { background: var(--panel-hover); text-shadow: none; }
.lg-ind-row .i-title { color: var(--text); font-weight: 500; }
.lg-ind-row .i-vals b { font-weight: 600; margin-right: 6px; }
.lg-ind-row .i-act {
  display: inline-flex;
  align-items: center;
  gap: 2px;
}
.lg-ind-row .i-act button {
  width: 18px;
  height: 18px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 11px;
  padding: 0;
}
.lg-ind-row .i-act button:hover { background: var(--chip-bg); color: var(--text); }
.lg-ind-row.ind-hidden .i-title, .lg-ind-row.ind-hidden .i-vals { opacity: 0.4; }

/* 底栏 */
.chart-bottombar {
  flex: none;
  display: flex;
  align-items: center;
  gap: 2px;
  height: 34px;
  padding: 0 8px;
  border-top: 1px solid var(--border);
  font-size: 14px;
}
.range-btn { padding: 4px 9px; border-radius: 6px; color: var(--muted); font-weight: 500; white-space: nowrap; }
.range-btn:hover { background: var(--panel-hover); color: var(--text); }
.range-btn.active { color: var(--text); background: var(--active-bg); font-weight: 600; }
.bottom-spacer { flex: 1; }
.bottom-clock { color: var(--muted); font-weight: 500; margin-right: 6px; white-space: nowrap; }
.scale-btn {
  padding: 3px 8px;
  border-radius: 5px;
  color: var(--muted);
  font-weight: 600;
  font-size: 12px;
  white-space: nowrap;
}
.scale-btn:hover { background: var(--panel-hover); color: var(--text); }
.scale-btn.active { color: var(--text); background: var(--active-bg); }
.chart-attribution, .site-attribution {
  color: var(--muted);
  font-size: 11px;
  line-height: 22px;
  text-align: center;
}
.chart-attribution {
  flex: none;
  min-height: 22px;
  border-top: 1px solid var(--border-soft);
}
.site-attribution { padding: 14px 16px 20px; }
.chart-attribution a, .site-attribution a { color: var(--accent); }
.chart-attribution a:hover, .site-attribution a:hover { text-decoration: underline; }
.mobile-detail { display: none; }

/* 右侧面板 + 图标栏 */
.chart-side {
  flex: none;
  width: 300px;
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--bg);
}
.chart-side.hidden-panel { display: none; }
.chart-side .watch-panel {
  border: none;
  border-radius: 0;
  position: static;
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: 1;
}
.chart-side .watch-rows { flex: 1; max-height: none; }
.side-panel {
  flex: 1;
  display: none;
  flex-direction: column;
  min-height: 0;
}
.side-panel.active { display: flex; }
.side-panel .sp-head {
  padding: 12px 14px 8px;
  font-weight: 700;
  font-size: 15px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.side-panel .sp-body { flex: 1; overflow-y: auto; }

.alert-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 14px;
  border-bottom: 1px solid var(--border-soft);
  font-size: 12.5px;
}
.alert-row .a-main { flex: 1; min-width: 0; }
.alert-row .a-main strong { display: block; font-size: 13px; }
.alert-row .a-main span { color: var(--muted); font-size: 11.5px; }
.alert-row.triggered .a-main strong { color: var(--star); }
.alert-row .a-del {
  width: 24px;
  height: 24px;
  border-radius: 5px;
  color: var(--muted);
}
.alert-row .a-del:hover { background: var(--panel-hover); color: var(--down); }

.icon-rail {
  flex: none;
  width: 44px;
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 6px 0;
  background: var(--bg);
}
.icon-rail .rail-btn {
  width: 34px;
  height: 34px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  position: relative;
}
.icon-rail .rail-btn:hover { background: var(--panel-hover); color: var(--text); }
.icon-rail .rail-btn.active { background: var(--accent-soft); color: var(--accent); }
.icon-rail .rail-btn .badge {
  position: absolute;
  top: 2px;
  right: 2px;
  min-width: 14px;
  height: 14px;
  border-radius: 7px;
  background: var(--down);
  color: #fff;
  font-size: 9px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 3px;
}

@media (max-width: 900px) {
  .chart-side, .icon-rail, .draw-rail { display: none; }
}

@media (max-width: 600px) {
  .site-header { gap: 8px; padding-inline: 12px; }
  .site-header .header-clock { display: none; }

  .chart-bottombar,
  .chart-attribution,
  .mobile-detail { display: none !important; }

  .chart-toolbar {
    min-height: 44px;
    height: 44px;
    flex-wrap: nowrap;
    gap: 1px;
    padding: 3px 4px;
  }
  .chart-toolbar > .brand,
  .chart-toolbar > .tb-sep,
  .chart-toolbar > #shotBtn,
  .chart-toolbar > #fsBtn,
  .chart-toolbar > #settingsBtn,
  .chart-toolbar > .header-spacer,
  .chart-toolbar > .main-nav,
  .chart-toolbar > #themeBtn { display: none; }
  .chart-toolbar .tb-btn { height: 32px; padding: 0 7px; }
  .chart-toolbar .symbol-btn {
    flex: 1 1 108px;
    min-width: 76px;
    max-width: 38vw;
    overflow: hidden;
    font-size: 12px;
  }
  .chart-toolbar .symbol-btn > span:not(.sym-icon):not(.caret) {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  #tfFavs { display: none !important; }
  #tfMoreBtn { padding-inline: 7px !important; }
  #tfMoreBtn .tf-current { display: inline; font-size: 12px; font-weight: 600; }
  #tfMenu {
    position: fixed;
    top: 42px;
    left: 8px;
    right: 8px;
    width: auto;
    min-width: 0 !important;
    max-height: calc(100dvh - 52px);
  }
  .chart-toolbar .symbol-btn .sym-icon { display: none; }
  #typeBtn { width: 32px; padding: 0; }
  #indBtn, #alertBtn { width: 32px; padding: 0; }
  #indBtn span, #alertBtn span { display: none; }

  .chart-body,
  .chart-stage,
  .chart-host { width: 100%; height: 100%; min-height: 0; }

  .chart-legend {
    top: 5px;
    left: 6px;
    max-width: calc(100% - 54px);
    font-size: 12px;
  }
  .chart-legend .lg-line1 {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto auto;
    align-items: center;
    gap: 3px 5px;
    font-size: 13px;
  }
  .chart-legend #lgTitle {
    min-width: 0;
    white-space: normal;
    line-height: 1.25;
  }
  .chart-legend .legend-symbol { display: none; }
  .chart-legend .lg-vals {
    grid-column: 1 / -1;
    gap: 5px;
    overflow: hidden;
    font-size: 12px;
    line-height: 1.35;
  }
  .chart-legend #lgInds { display: none; }

  .modal-overlay { padding: 10px 8px; align-items: center; }
  .modal { max-height: calc(100dvh - 20px); }
  .indicator-settings-modal { min-height: min(430px, calc(100dvh - 20px)); }

  .market-session-menu {
    width: calc(100% - 24px);
    padding: 14px 16px;
  }

}

/* Embedded mobile chart: use the same compact bottom toolbar in portrait and landscape. */
.mobile-chart-embed .chart-app { flex-direction: column; }
.mobile-chart-embed .chart-side,
.mobile-chart-embed .icon-rail,
.mobile-chart-embed .draw-rail,
.mobile-chart-embed .chart-bottombar,
.mobile-chart-embed .chart-attribution,
.mobile-chart-embed .mobile-detail { display: none !important; }
.mobile-chart-embed .chart-toolbar {
  order: 2;
  flex: none;
  min-height: 44px;
  height: 44px;
  flex-wrap: nowrap;
  gap: 1px;
  padding: 3px 4px;
  border-top: 1px solid var(--border);
  border-bottom: 0;
}
.mobile-chart-embed .chart-toolbar > .brand,
.mobile-chart-embed .chart-toolbar > .tb-sep,
.mobile-chart-embed .chart-toolbar > #shotBtn,
.mobile-chart-embed .chart-toolbar > #fsBtn,
.mobile-chart-embed .chart-toolbar > #settingsBtn,
.mobile-chart-embed .chart-toolbar > .header-spacer,
.mobile-chart-embed .chart-toolbar > .main-nav,
.mobile-chart-embed .chart-toolbar > #themeBtn,
.mobile-chart-embed #tfFavs { display: none !important; }
.mobile-chart-embed .chart-toolbar .tb-btn { height: 32px; padding: 0 7px; }
.mobile-chart-embed .chart-toolbar .symbol-btn {
  flex: 0 1 auto;
  width: auto;
  min-width: 66px;
  max-width: 42vw;
  overflow: hidden;
  font-size: 12px;
}
.mobile-chart-embed .chart-toolbar .symbol-btn > span:not(.sym-icon):not(.caret) {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}
.mobile-chart-embed .chart-toolbar .symbol-btn .sym-icon { display: none; }
.mobile-chart-embed #tfDropdown { flex: none; }
.mobile-chart-embed #tfMoreBtn { padding-inline: 7px !important; }
.mobile-chart-embed #tfMoreBtn .tf-current { display: inline; font-size: 12px; font-weight: 600; }
.mobile-chart-embed #typeDropdown { flex: none; margin-left: auto; }
.mobile-chart-embed #typeBtn,
.mobile-chart-embed #indBtn,
.mobile-chart-embed #mobileFullscreenBtn { width: 32px; padding: 0; }
.mobile-chart-embed #indBtn,
.mobile-chart-embed #mobileFullscreenBtn { margin-left: 7px; }
.mobile-chart-embed #indBtn span { display: none; }
.mobile-chart-embed #mobileFullscreenBtn { display: flex; align-items: center; justify-content: center; }
.mobile-chart-embed #mobileFullscreenBtn svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.mobile-chart-embed #mobileFullscreenBtn.active { background: var(--active-bg); color: var(--accent); }
.mobile-chart-embed #alertBtn { display: none !important; }
.mobile-chart-embed .chart-body,
.mobile-chart-embed .chart-stage,
.mobile-chart-embed .chart-host { order: 1; flex: 1; width: 100%; height: 100%; min-height: 0; }
.mobile-chart-embed #tfMenu {
  position: absolute;
  top: auto;
  bottom: 40px;
  left: 0;
  right: auto;
  width: min(252px, calc(100vw - 16px));
  min-width: 0 !important;
  max-height: min(340px, calc(100dvh - 54px));
}
.mobile-chart-embed #tfMenu.open {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 2px;
}
.mobile-chart-embed #tfMenu .custom-period,
.mobile-chart-embed #tfMenu .menu-title { grid-column: 1 / -1; }
.mobile-chart-embed #tfMenu .menu-title { padding: 5px 7px 2px; }
.mobile-chart-embed #tfMenu .menu-row { gap: 3px; padding: 5px 7px; font-size: 12px; }
.mobile-chart-embed #tfMenu .star { display: none; }
.mobile-chart-embed #typeMenu {
  top: auto;
  right: 0;
  bottom: 40px;
  left: auto;
  min-width: 154px !important;
  max-height: min(300px, calc(100dvh - 54px));
}

/* 警报创建小弹窗 */
.mini-dialog {
  position: fixed;
  z-index: 120;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 320px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow);
  padding: 16px;
  display: none;
}
.mini-dialog.open { display: block; }
.mini-dialog h3 { margin: 0 0 12px; font-size: 15px; }
.mini-dialog .field { margin-bottom: 10px; }
.mini-dialog .field label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.mini-dialog .field input {
  width: 100%;
  height: 32px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  padding: 0 10px;
  outline: none;
  font-size: 13px;
}
.mini-dialog .field input:focus { border-color: var(--accent); }
.mini-dialog .dlg-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 12px; }
.mini-dialog .dlg-actions .primary {
  background: var(--accent);
  color: #fff;
  border-radius: 6px;
  padding: 7px 14px;
  font-weight: 600;
}
.mini-dialog .dlg-actions .ghost { color: var(--muted); padding: 7px 10px; }
.mini-dialog .dlg-actions .ghost:hover { color: var(--text); }

/* Toast */
.toast-wrap {
  position: fixed;
  right: 16px;
  bottom: 50px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.toast {
  background: var(--panel);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 10px 14px;
  font-size: 13px;
  max-width: 320px;
  animation: toast-in 0.18s ease-out;
}
.toast.alert { border-left-color: var(--star); }
.toast.restock { border-left-color: var(--down); }
.toast strong { display: block; margin-bottom: 2px; }
.toast span { color: var(--muted); font-size: 12px; }
@keyframes toast-in {
  from { transform: translateX(20px); opacity: 0; }
  to { transform: none; opacity: 1; }
}

/* ============ 状态球（图例里的实时/延迟指示） ============ */
.status-ball {
  border: 0;
  padding: 0;
  display: inline-grid;
  width: 18px;
  height: 18px;
  place-items: center;
  border-radius: 50%;
  background: var(--chip-bg);
  flex: none;
  cursor: pointer;
  pointer-events: auto;
}
.status-ball::after {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--muted);
}
.status-ball.open {
  background: var(--up-soft);
  animation: ball-pulse 2.2s ease-out infinite;
}
.status-ball.open::after { background: var(--up); }
.status-ball.closed { background: rgba(41, 98, 255, 0.12); }
.status-ball.closed::after { background: #2962ff; }
@keyframes ball-pulse {
  0% { box-shadow: 0 0 0 0 rgba(8, 153, 129, 0.35); }
  70% { box-shadow: 0 0 0 6px rgba(8, 153, 129, 0); }
  100% { box-shadow: 0 0 0 0 rgba(8, 153, 129, 0); }
}

.market-session-menu {
  position: absolute;
  top: 42px;
  left: 150px;
  z-index: 35;
  display: none;
  width: min(336px, calc(100% - 24px));
  padding: 16px 18px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  box-shadow: var(--shadow);
}
.market-session-menu.visible { display: block; }
.session-title { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; font-size: 16px; }
.session-dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.session-dot.open, .session-segment.open { background: var(--up); }
.session-dot.closed, .session-segment.closed { background: #6f8fe8; }
.session-desc, .session-footer { color: var(--muted); font-size: 13px; line-height: 1.5; }
.session-desc strong { display: inline; margin: 0; color: var(--text); font-weight: 700; }
.session-progress-row { display: flex; align-items: flex-start; gap: 8px; margin: 12px 0 6px; }
.session-weekday { min-width: 28px; color: var(--muted); font-size: 12px; }
.session-progress-col { flex: 1; min-width: 0; }
.session-progress { position: relative; height: 6px; overflow: visible; border-radius: 999px; background: var(--chip-bg); }
.session-segment, .session-now { position: absolute; top: 0; height: 100%; }
.session-segment:first-child { border-radius: 999px 0 0 999px; }
.session-segment:nth-child(3) { border-radius: 0 999px 999px 0; }
.session-now { top: -5px; width: 2px; height: 16px; background: var(--text); }
.session-scale { position: relative; height: 16px; margin-top: 6px; color: var(--muted); font-size: 11px; }
.session-scale span { position: absolute; top: 0; transform: translateX(-50%); white-space: nowrap; }
.session-scale span:first-child { left: 0; transform: none; }

/* ============ 画线浮动小菜单 ============ */
.draw-menu {
  position: absolute;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 4px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow);
}
.draw-menu button, .draw-menu .dm-color {
  width: 30px;
  height: 28px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
.draw-menu button:hover, .draw-menu .dm-color:hover { background: var(--panel-hover); color: var(--text); }
.draw-menu .dm-color { position: relative; }
.draw-menu .dm-color input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}
.draw-menu .dm-color .swatch {
  width: 14px;
  height: 14px;
  border-radius: 4px;
  border: 1px solid var(--border);
  pointer-events: none;
}
.draw-menu .dm-sep { width: 1px; height: 18px; background: var(--border); margin: 0 3px; }
.draw-menu #dmWidth { width: auto; padding: 0 8px; }
.draw-menu #dmDelete:hover { color: var(--down); }

/* 画文本时的行内输入框 */
.draw-text-input {
  position: absolute;
  z-index: 41;
  height: 30px;
  min-width: 160px;
  padding: 0 10px;
  border: 1px solid var(--accent);
  border-radius: 6px;
  background: var(--panel);
  color: var(--text);
  font-size: 13px;
  outline: none;
  box-shadow: var(--shadow);
}

/* ============ 右栏可拖分隔条 ============ */
.panel-resizer {
  flex: none;
  height: 5px;
  cursor: ns-resize;
  background: transparent;
  border-top: 1px solid var(--border);
  position: relative;
  transition: background-color var(--ease);
}
.panel-resizer::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 1px;
  transform: translateX(-50%);
  width: 28px;
  height: 3px;
  border-radius: 2px;
  background: var(--border);
  transition: background-color var(--ease);
}
.panel-resizer:hover, .panel-resizer.dragging { background: var(--accent-soft); }
.panel-resizer:hover::after, .panel-resizer.dragging::after { background: var(--accent); }
.detail-card { overflow-y: auto; }

/* ============ 设置弹窗 ============ */
.set-layout { display: flex; min-height: 0; flex: 1; }
.set-nav {
  flex: none;
  width: 148px;
  border-right: 1px solid var(--border-soft);
  padding: 10px 8px;
}
.set-nav button {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 10px;
  border-radius: 6px;
  text-align: left;
  font-size: 13px;
}
.set-nav button:hover { background: var(--panel-hover); }
.set-nav button.active { background: var(--chip-bg); font-weight: 600; }
.set-body { flex: 1; overflow-y: auto; padding: 14px 20px; }
.set-group-title {
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.4px;
  margin: 4px 0 10px;
}
.set-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 36px;
  font-size: 13px;
}
.set-row label.grow { flex: 1; display: flex; align-items: center; gap: 8px; cursor: pointer; }
.set-row input[type="checkbox"] { width: 15px; height: 15px; accent-color: var(--accent); cursor: pointer; }
.set-row input[type="color"] {
  width: 30px;
  height: 24px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: none;
  cursor: pointer;
}
.set-row select {
  height: 30px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  outline: none;
  font-size: 13px;
  padding: 0 8px;
  max-width: 240px;
}
.set-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 20px;
  border-top: 1px solid var(--border-soft);
}
.btn-ghost { color: var(--muted); padding: 7px 12px; border-radius: 6px; }
.btn-ghost:hover { background: var(--panel-hover); color: var(--text); }
.btn-primary {
  background: var(--text);
  color: var(--bg);
  border-radius: 6px;
  padding: 7px 16px;
  font-weight: 600;
}

/* ============ 底栏时区菜单（向上弹出） ============ */
.tz-dropdown { position: relative; }
.tz-dropdown .tb-menu { top: auto; bottom: 32px; left: auto; right: 0; min-width: 220px; }
#tzBtn { display: flex; align-items: center; gap: 4px; }

/* 通用滚动条 */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--muted); }
