:root {
  --bg: #0a0b0d;
  --panel: #111318;
  --panel-2: #15181e;
  --line: #23262e;
  --line-soft: #1b1e25;
  --text: #e7e9ed;
  --muted: #8a919e;
  --faint: #5f6672;
  --gold: #e9b44c;
  --gold-dim: rgba(233, 180, 76, 0.14);
  --green: #35d399;
  --green-dim: rgba(53, 211, 153, 0.12);
  --red: #f0555a;
  --red-dim: rgba(240, 85, 90, 0.12);
  --radius: 10px;
  --mono: "JetBrains Mono", "SF Mono", Consolas, "Cascadia Mono", monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: "PingFang SC", "Microsoft YaHei", "Segoe UI", system-ui, sans-serif;
  font-size: 13px;
  -webkit-font-smoothing: antialiased;
}

body {
  overflow: hidden;
  background-image: radial-gradient(circle at 12% -10%, rgba(233, 180, 76, 0.06), transparent 42%);
}

button, input { font-family: inherit; }

.app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  padding: 10px 12px 0;
}

/* ---------- 顶栏 ---------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 28px;
  height: 60px;
  padding: 0 16px;
  background: linear-gradient(180deg, rgba(22, 25, 31, 0.9), rgba(17, 19, 24, 0.9));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  flex: none;
}

.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark {
  width: 26px; height: 26px; border-radius: 7px;
  background: linear-gradient(145deg, #f3cf79, #b9812a);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.18);
  position: relative;
}
.brand-mark::after {
  content: ""; position: absolute; inset: 8px 7px;
  border-left: 2px solid rgba(30, 22, 8, 0.75);
  border-bottom: 2px solid rgba(30, 22, 8, 0.75);
  transform: skewX(-18deg);
}
.brand-name { font-size: 14px; font-weight: 700; letter-spacing: 1.4px; }
.brand-sub { font-size: 11px; color: var(--faint); letter-spacing: 0.4px; }

.quote { display: flex; align-items: baseline; gap: 12px; }
.quote-price {
  font-family: var(--mono);
  font-size: 27px;
  font-weight: 600;
  letter-spacing: -0.5px;
  font-variant-numeric: tabular-nums;
}
.quote-chg {
  font-family: var(--mono);
  font-size: 13px;
  padding: 3px 8px;
  border-radius: 6px;
  background: var(--line-soft);
  color: var(--muted);
}
.quote-chg.up { color: var(--green); background: var(--green-dim); }
.quote-chg.down { color: var(--red); background: var(--red-dim); }

.quote-side { margin-left: auto; display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.quote-range { font-family: var(--mono); font-size: 11.5px; color: var(--muted); }
.quote-meta { display: flex; align-items: center; gap: 10px; font-size: 11px; color: var(--faint); }
.source-tag {
  padding: 2px 7px; border-radius: 999px;
  border: 1px solid rgba(233, 180, 76, 0.35);
  color: var(--gold); background: rgba(233, 180, 76, 0.07);
  font-size: 10.5px;
}
.market-tag {
  padding: 2px 7px; border-radius: 999px; font-size: 10.5px;
  border: 1px solid var(--line); color: var(--faint);
}
.market-tag.open { color: var(--green); border-color: rgba(53, 211, 153, .4); background: var(--green-dim); }
.market-tag.closed { color: var(--muted); border-color: var(--line); background: var(--line-soft); }

.btn-refresh {
  background: #1b1f26; color: var(--muted);
  border: 1px solid var(--line); border-radius: 6px;
  padding: 4px 10px; cursor: pointer; font-size: 11px;
  transition: color .15s, border-color .15s;
}
.btn-refresh:hover { color: var(--text); border-color: #333845; }
a.btn-refresh { text-decoration: none; display: inline-flex; align-items: center; }
.btn-refresh.event-near { color: var(--gold); border-color: rgba(233, 180, 76, .45); background: rgba(233, 180, 76, .08); }

/* ---------- 主体 ---------- */
.grid {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 386px;
  gap: 10px;
  padding: 10px 0;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  min-height: 0;
}

/* ---------- 图表 ---------- */
.chart-panel { overflow: hidden; }
.panel-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 9px 12px; border-bottom: 1px solid var(--line-soft);
  flex: none;
}
.tabs { display: flex; gap: 4px; background: #0d0f13; padding: 3px; border-radius: 7px; border: 1px solid var(--line-soft); }
.tab {
  border: 0; background: transparent; color: var(--muted);
  padding: 5px 11px; border-radius: 5px; cursor: pointer; font-size: 12px;
  transition: background .15s, color .15s;
}
.tab:hover { color: var(--text); }
.tab.active { background: #232833; color: #fff; }

.legend { display: flex; align-items: center; gap: 12px; color: var(--faint); font-size: 11px; }
.lg { display: inline-flex; align-items: center; gap: 5px; }
.sw { width: 14px; height: 2px; border-radius: 2px; display: inline-block; }
.sw-support { background: var(--green); }
.sw-resistance { background: var(--red); }
.sw-zone { background: var(--gold); opacity: .5; height: 8px; border-radius: 2px; }
.sw-tp { background: var(--green); opacity: .55; }
.sw-sl { background: var(--red); opacity: .6; }
.switch { display: inline-flex; align-items: center; gap: 4px; cursor: pointer; color: var(--muted); }
.switch input { accent-color: var(--gold); }

.chart-wrap { position: relative; flex: 1; min-height: 0; }
#chart { width: 100%; height: 100%; display: block; }
.chart-empty {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  color: var(--faint); font-size: 12px; letter-spacing: .5px;
  pointer-events: none;
}
.chart-empty.hidden { display: none; }

.stats {
  display: flex; flex-wrap: wrap; gap: 6px 18px;
  padding: 9px 14px; border-top: 1px solid var(--line-soft);
  font-size: 11px; color: var(--faint); flex: none;
}
.stats b { font-family: var(--mono); font-weight: 500; color: var(--muted); margin-left: 4px; }

/* ---------- 侧栏 ---------- */
.side { display: flex; flex-direction: column; gap: 9px; min-height: 0; overflow: hidden; }

/* ---------- 侧栏分页 ---------- */
.side-tabs {
  display: flex; gap: 4px; flex: none;
  background: #0d0f13; border: 1px solid var(--line-soft);
  border-radius: 8px; padding: 3px;
}
.side-tab {
  flex: 1; border: 0; background: transparent; color: var(--muted);
  font-size: 11.5px; padding: 6px 0; border-radius: 6px; cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 5px;
  transition: background .15s, color .15s;
}
.side-tab:hover { color: var(--text); }
.side-tab.active { background: #232833; color: #fff; }
.tab-badge {
  min-width: 16px; height: 16px; padding: 0 4px; border-radius: 999px;
  background: var(--gold); color: #1a1408;
  font-size: 9.5px; line-height: 16px; text-align: center;
  font-family: var(--mono);
}
.tab-badge.zero { background: var(--line); color: var(--faint); }
.side-view {
  display: flex; flex-direction: column; gap: 9px;
  flex: 1; min-height: 0; overflow-y: auto;
}
.side-view[hidden] { display: none; }

.regime { padding: 11px 13px; flex: none; }
.regime-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 5px; }
.regime-bias { font-size: 13px; font-weight: 600; }
.regime-bias.bull { color: var(--green); }
.regime-bias.bear { color: var(--red); }
.regime-bias.range { color: var(--gold); }
.regime-strength { font-size: 10.5px; color: var(--faint); border: 1px solid var(--line); padding: 1px 7px; border-radius: 999px; }
.regime-text { margin: 0; font-size: 11.5px; line-height: 1.55; color: var(--muted); }

.plan {
  position: relative;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 11px 13px 10px;
  flex: none;
  overflow: hidden;
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.plan:hover { border-color: #2c313b; }
.plan.active { border-color: rgba(233, 180, 76, 0.45); background: #13161b; }
.plan::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 2px;
}
.plan[data-side="long"]::before { background: var(--green); }
.plan[data-side="short"]::before { background: var(--red); }

.plan-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 7px; }
.plan-title { font-size: 12.5px; font-weight: 600; letter-spacing: .3px; }
.plan-status {
  font-size: 10.5px; padding: 2px 8px; border-radius: 999px;
  border: 1px solid var(--line); color: var(--faint);
}
.plan-status.ready { color: var(--green); border-color: rgba(53, 211, 153, .4); background: var(--green-dim); }
.plan-status.near { color: var(--gold); border-color: rgba(233, 180, 76, .4); background: var(--gold-dim); }
.plan-status.broken { color: var(--red); border-color: rgba(240, 85, 90, .4); background: var(--red-dim); }

.plan-price {
  display: flex; align-items: baseline; justify-content: space-between;
  padding: 7px 9px; margin-bottom: 8px;
  background: var(--panel-2); border-radius: 7px;
}
.plan-label { font-size: 11px; color: var(--faint); }
.plan-value { font-family: var(--mono); font-size: 16px; font-weight: 600; color: var(--gold); font-variant-numeric: tabular-nums; }

.plan-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 5px 12px; }
.plan-grid > div { display: flex; align-items: baseline; justify-content: space-between; }
.plan-grid .k { font-size: 11px; color: var(--faint); }
.plan-grid .v { font-family: var(--mono); font-size: 12px; color: var(--text); font-variant-numeric: tabular-nums; }
.v-sl { color: var(--red); }
.v-tp { color: var(--green); }

.plan-cond {
  margin: 8px 0 0; padding-top: 7px; border-top: 1px dashed var(--line-soft);
  font-size: 10.5px; line-height: 1.5; color: var(--faint);
}

.levels { flex: 1; min-height: 132px; }
.panel[hidden] { display: none; }

/* ---------- 计划跟进 ---------- */
.plan-actions { display: flex; align-items: center; gap: 6px; }
.plan-follow {
  background: transparent; color: var(--faint); border: 1px solid var(--line);
  border-radius: 6px; padding: 2px 8px; font-size: 10.5px; cursor: pointer;
  transition: color .15s, border-color .15s;
}
.plan-follow:hover { color: var(--gold); border-color: rgba(233, 180, 76, .45); }
.plan-follow:disabled { opacity: .45; cursor: default; }

.track { padding: 9px 12px; flex: 1; min-height: 0; overflow-y: auto; border-left: 2px solid rgba(233, 180, 76, .5); }
.track-empty { padding: 30px 8px; text-align: center; color: var(--faint); font-size: 11.5px; line-height: 1.9; }
.track-head { display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); margin-bottom: 4px; }
.track-count { color: var(--gold); font-family: var(--mono); }
.track-row { padding: 7px 0; border-top: 1px dashed var(--line-soft); }
.track-row:first-child { border-top: 0; padding-top: 2px; }
.track-top { display: flex; align-items: center; gap: 7px; }
.side-tag { font-size: 10px; padding: 1px 6px; border-radius: 4px; }
.side-tag.long { color: var(--green); background: var(--green-dim); }
.side-tag.short { color: var(--red); background: var(--red-dim); }
.track-state { font-size: 10.5px; color: var(--muted); }
.track-pl { margin-left: auto; font-family: var(--mono); font-size: 10.5px; color: var(--text); }
.track-close {
  background: transparent; border: 1px solid var(--line); color: var(--faint);
  border-radius: 5px; font-size: 10px; padding: 1px 6px; cursor: pointer;
}
.track-close:hover { color: var(--red); border-color: rgba(240, 85, 90, .4); }
.track-close.confirm { color: var(--red); border-color: rgba(240, 85, 90, .65); background: var(--red-dim); }
.track-guide { margin-top: 4px; font-size: 10.5px; color: var(--gold); line-height: 1.45; }

/* ---------- 复盘弹层 ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 50; padding: 24px;
  background: rgba(0, 0, 0, .62);
  display: flex; align-items: center; justify-content: center;
}
.overlay[hidden] { display: none; }
.overlay-box {
  width: min(820px, 100%); max-height: 86vh;
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  display: flex; flex-direction: column; overflow: hidden;
}
.overlay-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; border-bottom: 1px solid var(--line-soft);
}
.overlay-title { font-size: 13px; font-weight: 600; }
.overlay-stats {
  display: flex; gap: 20px; flex-wrap: wrap;
  padding: 10px 16px; font-size: 11px; color: var(--muted);
  border-bottom: 1px solid var(--line-soft);
}
.overlay-stats b { font-family: var(--mono); color: var(--text); margin-left: 4px; }
.overlay-body { overflow-y: auto; padding: 4px 10px 12px; }
.hist-table { width: 100%; border-collapse: collapse; font-size: 11px; }
.hist-table th {
  position: sticky; top: 0; background: var(--panel);
  text-align: left; color: var(--faint); font-weight: 400;
  padding: 7px 8px; border-bottom: 1px solid var(--line-soft);
}
.hist-table td {
  padding: 7px 8px; border-bottom: 1px solid var(--line-soft);
  color: var(--muted); font-family: var(--mono);
}
.hist-table td.lbl { font-family: inherit; color: var(--text); }
.hist-table .pos { color: var(--green); }
.hist-table .neg { color: var(--red); }
.hist-empty { padding: 30px; text-align: center; color: var(--faint); font-size: 12px; }
.levels-head {
  display: flex; justify-content: space-between;
  padding: 9px 13px; border-bottom: 1px solid var(--line-soft);
  font-size: 11px; color: var(--muted); flex: none;
}
.levels-head .hint { color: var(--faint); font-size: 10px; }
.levels-list { overflow-y: auto; padding: 3px 6px 6px; }
.level-row {
  display: grid; grid-template-columns: 5px 1fr auto auto; align-items: center; gap: 9px;
  padding: 6px 7px; border-radius: 6px;
}
.level-row:hover { background: var(--panel-2); }
.level-bar { width: 3px; height: 18px; border-radius: 2px; opacity: .85; }
.level-row.support .level-bar { background: var(--green); }
.level-row.resistance .level-bar { background: var(--red); }
.level-row.pivot .level-bar { background: var(--gold); }
.level-label { font-size: 11px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.level-price { font-family: var(--mono); font-size: 12px; font-variant-numeric: tabular-nums; }
.level-dist { font-family: var(--mono); font-size: 10.5px; color: var(--faint); min-width: 46px; text-align: right; }
.level-row.resistance .level-price { color: #ff8a8e; }
.level-row.support .level-price { color: #6ee7bd; }
.level-row.pivot .level-price { color: var(--gold); }

/* ---------- 底栏 ---------- */
.footer {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  height: 42px; flex: none; border-top: 1px solid var(--line);
  font-size: 11px; color: var(--faint);
}
.risk-ctrl { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }
.risk-ctrl .k { color: var(--faint); }
.risk-ctrl input {
  width: 70px; background: #0d0f13; color: var(--text);
  border: 1px solid var(--line); border-radius: 6px;
  padding: 4px 7px; font-family: var(--mono); font-size: 11.5px;
  outline: none;
}
.risk-ctrl input:focus { border-color: rgba(233, 180, 76, .5); }
.foot-note { display: flex; align-items: center; gap: 6px; color: var(--faint); }
.dot-sep { color: #33373f; }

/* ---------- 滚动条 ---------- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-thumb { background: #2b303a; border-radius: 3px; }
::-webkit-scrollbar-track { background: transparent; }

@media (max-height: 800px) and (min-width: 1121px) {
  .app { padding-top: 8px; }
  .grid { padding: 8px 0; gap: 8px; }
  .side { gap: 7px; }
  .regime { padding: 8px 12px; }
  .regime-text { font-size: 11px; line-height: 1.4; }
  .plan { padding: 8px 12px 7px; }
  .plan-head { margin-bottom: 4px; }
  .plan-price { margin-bottom: 5px; padding: 4px 8px; }
  .plan-value { font-size: 15px; }
  .plan-grid { gap: 2px 12px; }
  .plan-cond { margin-top: 5px; padding-top: 4px; font-size: 10px; line-height: 1.4; }
  .levels { min-height: 104px; }
  .levels-head { padding: 6px 12px; }
  .level-row { padding: 4px 7px; }
}

/* ---------- 响应式 ---------- */
@media (max-width: 1120px) {
  body { overflow: auto; }
  .app { height: auto; min-height: 100vh; }
  .grid { grid-template-columns: 1fr; }
  .chart-wrap { min-height: 420px; }
  .levels { max-height: 260px; }
  .quote-side { display: none; }
}

/* ---------- 新闻日历页 ---------- */
.cal-grid {
  flex: 1; min-height: 0;
  display: grid; grid-template-columns: 380px minmax(0, 1fr);
  gap: 10px; padding: 10px 0;
}
.cal-panel, .news-panel { min-height: 0; overflow: hidden; }
.cal-list, .news-list { flex: 1; overflow-y: auto; padding: 4px 12px 14px; }
.panel-head .hint { color: var(--faint); font-size: 10px; }

.cal-next {
  margin-left: auto; margin-right: 24px;
  display: flex; align-items: baseline; gap: 10px;
  font-size: 12px; color: var(--muted);
}
.cal-next-label { font-size: 10.5px; color: var(--faint); }
.cal-next-name { color: var(--gold); font-weight: 600; }
.cal-next-time { font-family: var(--mono); font-size: 11px; color: var(--muted); }

.cal-day {
  margin: 14px 0 4px; padding-bottom: 4px;
  font-size: 10.5px; letter-spacing: .5px; color: var(--faint);
  border-bottom: 1px solid var(--line-soft);
}
.cal-item {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 10px 8px; border-radius: 7px;
  border-bottom: 1px solid var(--line-soft);
}
.cal-item.today { background: rgba(233, 180, 76, .045); }
.cal-item.next { border-left: 2px solid rgba(233, 180, 76, .7); }
.cal-item.past { opacity: .42; }
.cal-time { width: 44px; font-family: var(--mono); font-size: 13px; color: var(--text); }
.cal-body { flex: 1; min-width: 0; }
.cal-name { font-size: 12.5px; color: var(--text); display: flex; align-items: center; gap: 7px; }
.impact {
  font-size: 9.5px; padding: 1px 5px; border-radius: 4px;
  border: 1px solid rgba(240, 85, 90, .35); color: var(--red);
}
.cal-note { margin-top: 3px; font-size: 10.5px; color: var(--faint); line-height: 1.45; }
.cal-count { font-family: var(--mono); font-size: 10.5px; color: var(--gold); white-space: nowrap; }

.news-item { padding: 9px 4px 9px 8px; border-bottom: 1px solid var(--line-soft); }
.news-item.high { border-left: 2px solid rgba(233, 180, 76, .75); }
.news-head { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.news-time { font-family: var(--mono); font-size: 10px; color: var(--faint); }
.news-src {
  font-size: 9.5px; color: var(--muted);
  border: 1px solid var(--line); border-radius: 4px; padding: 0 5px;
}
.news-flag {
  font-size: 9.5px; color: var(--gold);
  border: 1px solid rgba(233, 180, 76, .35); border-radius: 4px; padding: 0 5px;
}
.news-text { font-size: 12px; line-height: 1.65; color: var(--muted); }
.news-item.high .news-text { color: var(--text); }
.cal-empty, .news-empty { padding: 34px 10px; text-align: center; color: var(--faint); font-size: 12px; }

@media (max-width: 900px) {
  body { overflow: auto; }
  .app { height: auto; min-height: 100vh; }
  .cal-grid { grid-template-columns: 1fr; }
  .cal-panel { max-height: 46vh; }
  .news-panel { height: 62vh; }
  .cal-next { display: none; }
  .footer { height: auto; padding: 8px 0; flex-direction: column; align-items: flex-start; gap: 4px; }
}

@media (max-width: 720px) {
  .topbar { gap: 14px; padding: 0 12px; height: 56px; }
  .brand-sub, .quote-range, .legend .lg { display: none; }
  .quote-price { font-size: 22px; }
  .footer { height: auto; flex-direction: column; align-items: flex-start; padding: 8px 0; }
}
