:root {
  --ink: #2e3238;
  --muted: #7a8088;
  --line: #e4e7eb;
  --line-strong: #cfd4da;
  --header: #444;
  --header-active: #353535;
  --blue: #2d6cdf;
  --red: #e53935;
  --orange: #e58b20;
  --green: #279653;
  --surface: #fff;
  --wash: #f7f8fa;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body { background: #fff; color: var(--ink); font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", Arial, sans-serif; font-size: 14px; line-height: 1.5; }
button, input, select { font: inherit; }
button { cursor: pointer; }

.site-header { height: 50px; background: var(--header); color: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.12); }
.header-inner { width: min(1900px, calc(100% - 32px)); height: 50px; margin: 0 auto; display: flex; align-items: center; }
.brand { display: inline-flex; align-items: center; gap: 7px; color: #fff; text-decoration: none; font-size: 18px; font-weight: 600; white-space: nowrap; }
.brand-mark { display: inline-grid; place-items: center; width: 27px; height: 27px; border: 1px solid rgba(255,255,255,.72); font-size: 15px; line-height: 1; }
.primary-nav { display: flex; align-self: stretch; margin-left: 22px; }
.nav-group { position: relative; display: flex; align-items: stretch; }
.nav-item { border: 0; border-left: 1px solid rgba(255,255,255,.08); background: transparent; color: rgba(255,255,255,.91); padding: 0 15px; font-size: 15px; }
.nav-item:hover, .nav-item.active { background: var(--header-active); color: #fff; }
.caret { color: #bbb; font-size: 11px; margin-left: 3px; }
.nav-dropdown { position: absolute; z-index: 20; top: 50px; left: 0; display: none; min-width: 128px; padding: 5px 0; border: 1px solid #ddd; background: #fff; box-shadow: 0 4px 12px rgba(0,0,0,.15); }
.nav-group:hover .nav-dropdown, .nav-group:focus-within .nav-dropdown { display: flex; flex-direction: column; }
.nav-dropdown button { border: 0; background: transparent; color: #4d545b; padding: 8px 16px; text-align: left; font-size: 13px; white-space: nowrap; }
.nav-dropdown button:hover, .nav-dropdown button:focus { background: #f3f5f7; color: var(--blue); outline: 0; }
.header-actions { margin-left: auto; }
.header-action { color: #fff; border: 1px solid rgba(255,255,255,.38); background: transparent; padding: 5px 11px; font-size: 13px; }
.header-action:hover { background: rgba(255,255,255,.12); }

.page-shell { width: min(1900px, calc(100% - 32px)); margin: 0 auto; padding: 27px 0 40px; }
.page-heading { display: flex; align-items: flex-end; justify-content: space-between; padding: 0 2px 20px; border-bottom: 1px solid var(--line); }
.eyebrow { color: #9b7e48; font-size: 10px; letter-spacing: 1.8px; font-weight: 700; }
h1 { margin: 4px 0 2px; font-size: 27px; line-height: 1.15; font-weight: 600; letter-spacing: 0; }
.page-heading p { margin: 0; color: var(--muted); font-size: 13px; }
.date-control { display: flex; align-items: center; gap: 9px; color: var(--muted); font-size: 13px; }
.date-control select { min-width: 145px; height: 34px; border: 1px solid var(--line-strong); color: var(--ink); background: #fff; padding: 0 28px 0 10px; outline: none; }
.date-control select:focus { border-color: var(--blue); }

.toolbar { min-height: 60px; display: flex; align-items: center; gap: 18px; border-bottom: 1px solid var(--line); }
.search-box { width: 260px; display: flex; align-items: center; border: 1px solid var(--line-strong); height: 34px; background: #fff; }
.search-box:focus-within { border-color: var(--blue); }
.search-icon { width: 32px; color: #8a919a; text-align: center; font-size: 20px; line-height: 1; transform: rotate(-20deg); }
.search-box input { flex: 1; min-width: 0; height: 32px; border: 0; outline: 0; padding: 0 8px 0 0; color: var(--ink); background: transparent; }
.search-box input::placeholder { color: #a5abb1; }
.filter-group { display: inline-flex; align-items: center; gap: 4px; }
.filter-btn { height: 30px; border: 1px solid transparent; background: transparent; color: #66707a; padding: 0 9px; font-size: 13px; }
.filter-btn:hover { color: var(--ink); background: var(--wash); }
.filter-btn.selected { border-color: var(--line-strong); background: #f1f3f5; color: var(--ink); }
.dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 3px; vertical-align: 1px; }
.success-dot { background: var(--red); }
.zha-dot { background: var(--orange); }
.fail-dot { background: #a8adb3; }
.toolbar-note { margin-left: auto; color: #9a9fa6; font-size: 12px; white-space: nowrap; }

.metrics { display: grid; grid-template-columns: repeat(4, minmax(120px, 1fr)) minmax(250px, 1.8fr); gap: 0; margin-top: 20px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); background: var(--surface); }
.metric { min-height: 78px; padding: 15px 20px; border-right: 1px solid var(--line); }
.metric:last-child { border-right: 0; }
.metric-label { display: block; color: var(--muted); font-size: 12px; }
.metric strong { display: inline-block; margin-top: 2px; font-size: 25px; line-height: 1.15; font-weight: 600; color: var(--ink); }
.metric-sub { color: #9ca1a7; font-size: 12px; margin-left: 4px; }
.metric-positive strong { color: var(--red); }
.metric-warm strong { color: var(--orange); }
.metric-muted strong { color: #737a82; }
.theme-list { display: flex; flex-wrap: wrap; gap: 4px 8px; margin-top: 5px; }
.theme-list button { border: 1px solid #e3e7eb; border-radius: 2px; padding: 2px 6px; background: #f5f7f9; color: #5c6670; font-size: 12px; }
.theme-list button:hover { color: var(--blue); text-decoration: underline; }
.theme-list button.theme-active { border-color: #e2cf00; background: #fff200; color: #242424; }

.sector-toolbar { min-height: 60px; display: flex; align-items: center; gap: 16px; border-bottom: 1px solid var(--line); }
.segmented { display: inline-flex; border: 1px solid var(--line-strong); }
.sector-type { border: 0; border-right: 1px solid var(--line-strong); background: #fff; color: #6a727a; padding: 6px 15px; font-size: 13px; }
.sector-type:last-child { border-right: 0; }
.sector-type.active { background: #edf3ff; color: var(--blue); }
.timeline-control { display: flex; align-items: center; gap: 9px; flex: 1; min-width: 250px; color: #747c84; font-size: 13px; }
.timeline-control input { flex: 1; accent-color: var(--blue); }
#sectorTimeLabel { min-width: 43px; color: #3f4850; font-variant-numeric: tabular-nums; }
.sector-summary { display: grid; grid-template-columns: repeat(4, 1fr); border-bottom: 1px solid var(--line); margin-top: 20px; }
.sector-summary > div { min-height: 76px; padding: 13px 18px; border-right: 1px solid var(--line); }
.sector-summary > div:last-child { border-right: 0; }
.sector-summary span { display: block; color: var(--muted); font-size: 12px; }
.sector-summary strong { display: block; margin-top: 3px; color: var(--ink); font-size: 17px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sector-summary > div:first-child strong { color: var(--red); }
.sector-summary > div:nth-child(2) strong { color: var(--green); }
.sector-layout { display: grid; grid-template-columns: minmax(0, 2.2fr) minmax(270px, .8fr); gap: 18px; margin-top: 20px; }
.sector-chart-panel, .sector-side-panel, .sector-table-panel { border: 1px solid var(--line); background: #fff; box-shadow: 0 2px 10px rgba(0,0,0,.05); }
.panel-heading { min-height: 45px; display: flex; align-items: center; justify-content: space-between; padding: 0 14px; border-bottom: 1px solid var(--line); }
.panel-heading h2 { margin: 0; color: #3d444b; font-size: 15px; font-weight: 600; }
.panel-heading span { color: #9aa0a7; font-size: 11px; }
.sector-chart-wrap { position: relative; height: 620px; padding: 10px 12px 8px; }
#sectorCanvas { display: block; width: 100%; height: 100%; }
.sector-empty { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; color: #959ca3; font-size: 14px; line-height: 2; }
.sector-empty[hidden] { display: none; }
.sector-empty small { color: #b0b5ba; font-size: 12px; }
.momentum-list { max-height: 620px; overflow-y: auto; }
.momentum-item { display: grid; grid-template-columns: 26px minmax(0, 1fr) auto; align-items: center; gap: 7px; min-height: 46px; padding: 6px 13px; border-bottom: 1px solid #f0f1f2; font-size: 12px; }
.momentum-rank { color: #a0a6ac; font-variant-numeric: tabular-nums; }
.momentum-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #4a535b; }
.momentum-value { font-variant-numeric: tabular-nums; }
.momentum-value.up { color: var(--red); }
.momentum-value.down { color: var(--green); }
.sector-table-panel { margin-top: 18px; }
.sector-table-scroll { overflow-x: auto; }
.sector-table { width: 100%; border-collapse: collapse; text-align: left; font-size: 12px; }
.sector-table th, .sector-table td { border-bottom: 1px solid var(--line); padding: 8px 12px; white-space: nowrap; }
.sector-table th { color: #7c838a; background: #fafafa; font-weight: 500; }
.sector-table td { color: #4d555d; }
.sector-table td:nth-child(2) { color: #303940; font-weight: 500; }
.sector-table .flow-up { color: var(--red); }
.sector-table .flow-down { color: var(--green); }
.theme-list em { color: #a1a7ad; font-style: normal; margin-left: 2px; }

.rank-section { margin-top: 20px; box-shadow: 0 2px 12px rgba(0,0,0,.08); border: 1px solid var(--line); background: #fff; }
.section-bar { min-height: 48px; display: flex; align-items: center; justify-content: space-between; padding: 0 12px 0 15px; border-bottom: 1px solid var(--line); }
.section-bar h2 { display: inline; margin: 0; font-size: 16px; font-weight: 600; }
.section-date { margin-left: 10px; color: #9b7e48; font-size: 12px; }
.section-tools { display: inline-flex; align-items: center; gap: 10px; }
.result-count { color: #989ea5; font-size: 12px; }
.quiet-btn { color: #6f767d; border: 1px solid var(--line-strong); background: #fff; padding: 4px 9px; font-size: 12px; }
.quiet-btn:hover { color: var(--blue); border-color: var(--blue); }
.table-scroll { overflow-x: auto; }
.ladder-table { width: 100%; border-collapse: collapse; table-layout: fixed; text-align: center; font-size: 13px; }
.ladder-table th, .ladder-table td { border: 1px solid var(--line); }
.ladder-table thead th { height: 39px; color: #454c54; background: #fafafa; font-weight: 600; }
.ladder-table .progress-col { width: 100px; }
.ladder-table .ratio-col { width: 110px; }
.ladder-table tbody td { vertical-align: top; }
.ladder-table tbody tr:hover { background: #fcfdff; }
.ladder-table tbody td:first-child { padding: 13px 7px; color: #454c54; font-weight: 500; white-space: nowrap; }
.ladder-table tbody td:nth-child(2) { padding: 13px 7px; color: #66707a; white-space: nowrap; }
.stock-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); text-align: left; }
.stock-entry { position: relative; display: flex; align-items: center; min-height: 35px; gap: 5px; padding: 2px 11px; border-bottom: 1px solid #f0f1f2; white-space: nowrap; overflow: hidden; }
.stock-entry:nth-last-child(-n+1) { border-bottom: 0; }
.stock-entry:hover { background: #f8faff; }
.stock-market { flex: 0 0 auto; color: #4f5963; font-size: 13px; line-height: 1.2; }
.stock-name { border: 0; background: transparent; padding: 0; cursor: pointer; }
.stock-name:hover { text-decoration: underline; }
.stock-name { min-width: 0; max-width: 110px; flex: 0 1 auto; color: #0d6efd; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: left; }
.stock-name.theme-highlight { background: #fff200; color: #242424; padding: 0 2px; text-decoration: none; }
.stock-meta { display: contents; color: #9299a1; font-size: 11px; }
.status-pair { display: inline-flex; align-items: center; color: #4f4f4f; font-size: 13px; line-height: 1.2; }
.status-pair::before { content: "（"; }
.status-pair::after { content: "）"; }
.status-badge { display: inline-block; min-width: 19px; padding: 1px 3px; text-align: center; font-size: 12px; line-height: 1.15; vertical-align: 1px; }
.status-pair.status-success .status-badge { background: var(--red); color: #fff; }
.status-pair.status-zha .status-badge { background: var(--orange); color: #fff; }
.status-pair.status-fail .status-badge { background: #f5f5f5; color: #777; border: 1px solid #e5e5e5; }
.change-bracket { color: #4f4f4f; font-size: 13px; white-space: nowrap; }
.change-up { color: var(--red); font-weight: 600; }
.change-down { color: var(--green); }
.theme-tag { color: #4f5963; font-size: 13px; text-decoration: none; border-bottom: 1px dotted #aeb4ba; cursor: pointer; }
.theme-tag:hover { color: var(--blue); border-color: var(--blue); }
.theme-tag.theme-highlight-tag { background: #fff200; color: #242424; padding: 0 2px; border-bottom: 0; }
.stock-entry.is-filtered-out { display: none; }
.ladder-table tbody tr.hidden-row { display: none; }
.loading { height: 120px; color: #9ba1a8; }
.empty-state { padding: 45px 16px 50px; text-align: center; color: #899098; }
.empty-state strong, .empty-state span { display: block; }
.empty-state strong { margin: 3px 0; color: #60676f; font-size: 14px; }
.empty-icon { font-size: 26px; transform: rotate(-20deg); }

.kline-modal { position: fixed; inset: 0; z-index: 30; display: grid; place-items: center; }
.kline-modal[hidden] { display: none; }
.kline-backdrop { position: absolute; inset: 0; background: rgba(20, 25, 30, .46); }
.kline-dialog { position: relative; z-index: 1; width: min(850px, calc(100vw - 28px)); background: #fff; box-shadow: 0 12px 38px rgba(0,0,0,.25); }
.kline-header { height: 52px; display: flex; align-items: center; justify-content: space-between; padding: 0 15px 0 18px; border-bottom: 1px solid var(--line); }
.kline-header h2 { display: inline; margin: 0 8px 0 0; font-size: 17px; font-weight: 600; }
.kline-code { color: #7e858d; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 12px; }
.kline-close { border: 0; background: transparent; color: #777e85; padding: 0 5px; font-size: 27px; line-height: 1; }
.kline-close:hover { color: var(--ink); }
.kline-tabs { display: flex; gap: 3px; padding: 9px 16px 0; border-bottom: 1px solid var(--line); }
.kline-tab { border: 0; border-bottom: 2px solid transparent; background: transparent; color: #737a82; padding: 5px 11px 8px; font-size: 13px; }
.kline-tab.active { border-bottom-color: var(--blue); color: var(--blue); }
.kline-info { min-height: 31px; padding: 8px 17px 2px; color: #747b82; font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kline-info .up { color: var(--red); }
.kline-info .down { color: var(--green); }
.kline-info .ma5 { color: #39aef2; }
.kline-info .ma10 { color: #f29d36; }
.kline-info .ma20 { color: #df69ef; }
.kline-chart-wrap { position: relative; height: 430px; padding: 10px 14px 8px; }
#klineCanvas { display: block; width: 100%; height: 100%; }
.kline-loading { position: absolute; inset: 0; display: grid; place-items: center; color: #999fa6; font-size: 13px; pointer-events: none; }
.kline-loading[hidden] { display: none; }
.kline-foot { padding: 7px 17px 10px; border-top: 1px solid var(--line); color: #a1a6ac; font-size: 11px; }

.insight-band { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-top: 18px; padding: 13px 15px; border-top: 1px solid #eadfca; border-bottom: 1px solid #eadfca; background: #fffdf8; color: #77705f; font-size: 12px; }
.insight-band p { display: inline; margin: 0 0 0 12px; }
.insight-kicker { color: #9b7e48; font-weight: 600; }
.data-source { color: #aaa18e; white-space: nowrap; }
.site-footer { margin-top: 20px; padding: 20px 12px; background: #2a2730; color: #c9c7cc; text-align: center; font-size: 12px; line-height: 1.8; }
.site-footer div + div { color: #8f8c94; }
.muted { color: #a3a8ae; font-size: 12px; }

@media print {
  .site-header, .toolbar, .date-control, .section-tools, .insight-band, .site-footer { display: none !important; }
  .page-shell { width: 100%; padding: 0; }
  .page-heading { border: 0; padding: 0 0 12px; }
  .metrics { margin-top: 0; box-shadow: none; }
  .rank-section { margin-top: 12px; box-shadow: none; }
}

@media (max-width: 1080px) and (min-width: 761px) {
  .stock-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .sector-layout { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 760px) {
  .header-inner { width: calc(100% - 16px); }
  .brand { font-size: 16px; }
  .primary-nav { margin-left: 8px; }
  .nav-item { padding: 0 8px; font-size: 13px; }
  .header-action span { display: none; }
  .page-shell { width: calc(100% - 16px); padding-top: 19px; }
  .page-heading { align-items: flex-start; gap: 15px; flex-direction: column; }
  .date-control { width: 100%; justify-content: space-between; }
  .date-control select { flex: 1; max-width: 210px; }
  .toolbar { flex-wrap: wrap; gap: 8px 10px; padding: 12px 0; }
  .search-box { width: 100%; }
  .toolbar-note { width: 100%; margin-left: 0; text-align: right; }
  .sector-toolbar { flex-wrap: wrap; gap: 9px; padding: 11px 0; }
  .timeline-control { order: 3; width: 100%; min-width: 0; }
  .sector-toolbar .toolbar-note { order: 4; }
  .sector-summary { grid-template-columns: repeat(2, 1fr); }
  .sector-summary > div:nth-child(2) { border-right: 0; }
  .sector-summary > div:nth-child(3), .sector-summary > div:nth-child(4) { border-top: 1px solid var(--line); }
  .sector-summary > div:nth-child(4) { border-right: 0; }
  .sector-layout { grid-template-columns: minmax(0, 1fr); }
  .sector-chart-wrap { height: 520px; }
  .metrics { grid-template-columns: repeat(2, 1fr); }
  .metric { min-height: 68px; padding: 11px 13px; }
  .metric:nth-child(2) { border-right: 0; }
  .metric:nth-child(4) { border-right: 0; }
  .themes-metric { grid-column: 1 / -1; border-top: 1px solid var(--line); }
  .ladder-table { min-width: 650px; }
  .stock-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .insight-band { align-items: flex-start; flex-direction: column; gap: 7px; }
  .insight-band p { display: block; margin: 4px 0 0; }
  .data-source { white-space: normal; }
}
