:root {
  color-scheme: dark;
  --bg: #0b111c;
  --panel: #111b2a;
  --raised: #172335;
  --sidebar: #0e1725;
  --ink: #e1e8f2;
  --muted: #8f9fb5;
  --line: #253248;
  --accent: #79abff;
  --teal: #79abff;
  --red: #ff7b86;
  --green: #49d6ac;
  --mono: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 13px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans TC", sans-serif; }
button, input, select { font: inherit; }
button, a, summary { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .45; }
a { color: inherit; text-decoration: none; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: 23px; font-weight: 650; letter-spacing: .5px; }
h2 { margin: 0; font-size: 14px; font-weight: 600; }
h3 { font-size: 14px; }
.sidebar { position: fixed; inset: 0 auto 0 0; width: 196px; display: flex; flex-direction: column; padding: 26px 15px; background: var(--sidebar); border-right: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 10px; padding: 0 8px; font-size: 19px; font-weight: 650; }
.brand-icon { display: grid; place-items: center; width: 30px; height: 32px; color: var(--accent); font-size: 27px; }
.brand small { display: block; color: var(--muted); font-size: 8px; font-weight: 500; letter-spacing: 1.4px; margin-top: 3px; }
.nav-label { margin: 36px 10px 10px; color: #6f819a; font-size: 11px; }
.nav-item { display: flex; align-items: center; gap: 11px; width: 100%; padding: 12px 11px; border: 1px solid transparent; border-radius: 5px; margin-bottom: 5px; background: transparent; color: #a7b6c9; text-align: left; white-space: nowrap; }
.nav-item:hover { background: var(--raised); color: var(--ink); }
.nav-item.active { background: #1a2c47; border-color: #2a456b; color: #c8ddff; }
.nav-number { color: var(--muted); font: 11px var(--mono); }
.nav-item.active .nav-number { color: var(--accent); }
.nav-help { margin-top: 22px; color: var(--muted); font-size: 12px; }
.sidebar-bottom { margin-top: auto; border-top: 1px solid var(--line); padding: 17px 8px 0; font-size: 11px; color: var(--muted); }
.sidebar-bottom p { margin: 8px 0 0; font-size: 10px; color: #70849f; }
.dot { display: inline-block; width: 5px; height: 5px; margin-right: 7px; border-radius: 50%; background: var(--accent); vertical-align: middle; }
main { max-width: 2000px; margin-left: 196px; padding: 0 28px 26px; }
.topbar { display: flex; align-items: center; justify-content: space-between; height: 45px; border-bottom: 1px solid var(--line); font-size: 11px; }
.breadcrumb { color: var(--muted); }
.breadcrumb span { margin: 0 12px; color: #4d617d; }
.local-badge { color: var(--muted); border: 1px solid var(--line); border-radius: 3px; padding: 2px 7px; font-size: 10px; }
.hero { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 20px 0 18px; }
.hero-date { text-align: right; color: #bdcadb; font: 12px var(--mono); }
.hero-date small { display: block; margin-top: 4px; color: var(--muted); font: 11px/1.5 -apple-system, sans-serif; }
.eyebrow { color: var(--muted); font-size: 11px; }
.filter-card, .results-card { background: var(--panel); border: 1px solid var(--line); border-radius: 6px; }
.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 13px 18px; border-bottom: 1px solid var(--line); }
.heading-icon { color: var(--accent); margin-right: 8px; }
.text-button { border: 0; background: transparent; color: var(--muted); padding: 4px 2px; min-height: 28px; font-size: 11px; }
.text-button:hover { color: var(--accent); }
.filter-grid { display: grid; grid-template-columns: 1.3fr .9fr 1fr 1fr; gap: 18px; padding: 17px 18px; }
.field label { display: block; margin-bottom: 7px; font-size: 12px; color: #bac7d9; }
.field small { display: block; margin-top: 5px; font-size: 10px; color: var(--muted); }
.range-input { display: flex; align-items: center; gap: 8px; }
.range-input > div { width: calc(50% - 9px); }
.range-input > div, .single-input { display: flex; align-items: center; height: 36px; padding: 0 10px; border: 1px solid #34445c; border-radius: 4px; background: var(--bg); }
.range-input span, .single-input span { color: var(--muted); font-size: 11px; }
input[type=number] { min-width: 0; width: 100%; border: 0; background: transparent; color: var(--ink); font: 13px var(--mono); }
input[type=number]:focus { outline: 0; }
.range-input > div:focus-within, .single-input:focus-within, .search:focus-within { outline: 1px solid var(--accent); border-color: var(--accent); }
select { color: var(--ink); background: var(--bg); border: 1px solid #34445c; border-radius: 4px; padding: 7px 10px; }
.select-wrap select { height: 36px; width: 100%; font-size: 12px; }
.filter-action { align-self: end; padding-bottom: 0; }
.primary-button, .secondary-button { display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 36px; border: 1px solid #34445c; border-radius: 4px; padding: 0 13px; white-space: nowrap; font-size: 12px; }
.primary-button { background: #346bcc; border-color: #4a82e2; color: #fff; }
.primary-button:hover:enabled { background: #427bdd; }
.filter-action .primary-button { width: 100%; }
.secondary-button { background: var(--raised); color: #c2d0e2; }
.secondary-button:hover:enabled { border-color: #7395c3; background: #1d304a; }
.live-controls { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; padding: 0 18px 13px; font-size: 11px; color: var(--muted); }
.live-toggle { display: inline-flex; align-items: center; gap: 7px; color: #b6c7dd; cursor: pointer; }
.live-toggle input { width: 15px; height: 15px; accent-color: var(--accent); }
.live-controls select { padding: 4px 7px; font-size: 11px; }
.live-controls > span { font-variant-numeric: tabular-nums; }
.filter-footer { display: flex; gap: 7px; padding: 9px 18px; border-top: 1px solid var(--line); color: var(--muted); font-size: 11px; line-height: 1.6; }
.metrics { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin: 14px 0; }
.metric { position: relative; padding: 13px 17px; border: 1px solid var(--line); border-radius: 5px; background: var(--panel); }
.metric > span { color: var(--muted); font-size: 11px; }
.metric > div { display: flex; align-items: baseline; gap: 7px; margin-top: 5px; }
.metric strong { color: var(--ink); font: 600 27px/1.2 var(--mono); }
.metric:first-child { border-top: 2px solid var(--accent); }
.metric:first-child strong { color: var(--accent); }
.metric small { color: var(--muted); font-size: 10px; }
.metric p { margin: 6px 0 0; color: #8295af; font-size: 10px; line-height: 1.5; }
.metric .text-button { min-height: 20px; font-size: 10px; }
.results-header { display: flex; justify-content: space-between; align-items: center; gap: 14px; padding: 13px 18px; }
.results-header h2 { display: flex; align-items: center; gap: 8px; }
.results-header p { margin: 4px 0 0; color: var(--muted); font-size: 11px; }
.count-pill { display: inline-block; background: #20324e; color: var(--accent); padding: 1px 6px; border-radius: 3px; font: 11px var(--mono); }
.toolbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 0 18px 13px; }
.toolbar .field { display: flex; align-items: center; gap: 8px; }
.toolbar .field label { margin: 0; font-size: 11px; }
.toolbar select { font-size: 11px; }
.segments { display: flex; gap: 3px; border: 1px solid var(--line); border-radius: 4px; padding: 3px; background: var(--bg); }
.segment { border: 0; border-radius: 3px; padding: 5px 12px; background: transparent; color: var(--muted); font-size: 11px; min-height: 28px; }
.segment.active { color: #c9dfff; background: #203653; }
.search { display: flex; align-items: center; gap: 7px; height: 34px; padding: 0 9px; border: 1px solid #34445c; border-radius: 4px; background: var(--bg); color: var(--muted); }
.search > span { font-size: 20px; }
.search input { width: 160px; min-width: 0; outline: 0; border: 0; background: transparent; color: var(--ink); font-size: 12px; }
.search input::placeholder { color: #7f91aa; }
.search button { border: 0; color: var(--muted); background: transparent; font-size: 18px; }
.table-wrap { overflow: auto; max-height: 68vh; scrollbar-color: #3b506d transparent; }
table { width: 100%; border-collapse: collapse; text-align: left; white-space: nowrap; font-variant-numeric: tabular-nums; }
thead { position: sticky; top: 0; z-index: 1; background: #182536; }
th { height: 36px; border-block: 1px solid var(--line); padding: 7px 13px; color: #9fb1c9; font-size: 11px; font-weight: 500; }
th button { background: transparent; border: 0; padding: 0; font: inherit; color: inherit; }
th button:hover { color: var(--accent); }
th button span { color: #6986ad; margin-left: 3px; }
th small { color: #8ba0bc; font-size: 9px; }
td { height: 48px; padding: 8px 13px; border-bottom: 1px solid #1f2c3f; color: #c1cee0; font-size: 12px; }
th:first-child, td:first-child { padding-left: 18px; }
th:last-child, td:last-child { padding-right: 18px; }
tbody tr { cursor: pointer; }
tbody tr:hover { background: #1a2940; }
tr:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; background: #192b45; }
.numeric { text-align: right; font-family: var(--mono); }
.index-col { width: 30px; color: #647b98; font: 10px var(--mono); }
.stock-code { display: inline; margin-right: 10px; color: #e1ebfa; font: 600 12px var(--mono); }
.stock-name { display: inline; color: #acbed5; font-size: 12px; }
.market-tag { display: inline-block; padding: 1px 5px; border: 1px solid #324359; border-radius: 3px; color: #8fa9cb; font-size: 10px; }
.market-tag.otc { border-color: #4c4469; color: #b5a2d7; }
.price-cell { color: #e5edf8; }
.gain { color: var(--red); font-weight: 600; }
.loss { color: var(--green); }
.ratio-value { color: var(--accent); font-weight: 600; }
.ratio-cell { min-width: 92px; }
.ratio-meter { display: inline-block; vertical-align: middle; width: 35px; height: 4px; margin-left: 8px; appearance: none; background: #253650; border: 0; border-radius: 2px; }
.ratio-meter::-webkit-meter-bar { height: 4px; background: #253650; border: 0; }
.ratio-meter::-webkit-meter-optimum-value { background: #668fd1; }
.ratio-meter::-moz-meter-bar { background: #668fd1; }
.time-cell { color: #8095b0; font: 11px var(--mono); }
.row-arrow { color: #547298; font-size: 15px; }
.strategy-table { min-width: 790px; }
.strategy-table td:nth-child(n+4) { font-family: var(--mono); font-size: 11px; }
.strategy-table td:first-child { color: #e2ebf8; font-weight: 500; }
.strategy-table .score-cell { font: 600 12px var(--mono); color: #c2d9ff; }
td[data-state]::before { display: inline-block; content: ''; width: 5px; height: 5px; background: currentColor; border-radius: 50%; margin-right: 7px; vertical-align: middle; }
td[data-state=signal] { color: var(--red); }
td[data-state=watch] { color: var(--accent); }
td[data-state=pending] { color: #ebbc72; }
td[data-state=muted] { color: #8295af; }
.table-footer { display: flex; justify-content: space-between; gap: 12px; padding: 10px 18px; border-top: 1px solid var(--line); font-size: 10px; color: var(--muted); }
.page-footer { display: flex; justify-content: space-between; align-items: center; padding-top: 12px; color: #7186a3; font-size: 10px; }
.message { border: 1px solid #635338; border-radius: 4px; background: #29251f; color: #e4c590; padding: 9px 13px; font-size: 12px; line-height: 1.6; margin-bottom: 12px; }
.message.error { border-color: #75444f; background: #2e202b; color: #f0a0ac; }
.scan-progress { padding: 11px 18px; border-top: 1px solid var(--line); color: var(--muted); font-size: 11px; }
.scan-progress > div { display: flex; align-items: center; justify-content: space-between; }
progress { display: block; appearance: none; width: 100%; height: 4px; margin-top: 8px; border: 0; border-radius: 2px; background: #263650; }
progress::-webkit-progress-bar { background: #263650; }
progress::-webkit-progress-value { background: var(--accent); }
progress::-moz-progress-bar { background: var(--accent); }
.loading-state { display: flex; align-items: center; justify-content: center; gap: 9px; padding: 24px; color: var(--muted); font-size: 12px; }
.loading-ring { width: 15px; height: 15px; border-radius: 50%; border: 2px solid #30405b; border-top-color: var(--accent); animation: spin 1s linear infinite; }
.empty-state { text-align: center; padding: 36px 18px; color: var(--muted); }
.empty-state > span { color: #6d84a3; font-size: 28px; }
.empty-state h3 { margin: 8px 0; color: #bfcee1; font-size: 14px; font-weight: 500; }
.empty-state p { margin: 0; font-size: 12px; }
.strategy-rules { margin: 0 18px; border-bottom: 1px solid var(--line); }
summary { cursor: pointer; color: #a9bbd2; font-size: 12px; padding: 11px 0; }
summary:hover { color: var(--accent); }
details:not([open]) > :not(summary) { display: none; }
.strategy-rules > summary span { float: right; color: #788da9; font-size: 11px; }
.strategy-steps { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; padding: 0 0 15px; }
.strategy-steps article { border-left: 2px solid #375276; padding: 4px 12px; }
.strategy-steps article > span { color: var(--accent); font-size: 10px; }
.strategy-steps h3 { font-size: 13px; margin: 6px 0; color: #d1deee; }
.strategy-steps p { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.8; }
.strategy-controls { display: flex; align-items: end; flex-wrap: wrap; gap: 12px; padding: 15px 18px; }
.strategy-controls select { min-width: 200px; }
.strategy-controls .primary-button { min-width: 115px; }
.strategy-explanation { margin-top: 14px; padding: 0 18px; }
.strategy-explanation > summary { padding: 12px 0; }
.explanation-body { padding: 4px 0 15px; }
.explanation-body h2 { margin: 12px 0 6px; font-size: 13px; }
.explanation-body p { margin-bottom: 10px; color: var(--muted); font-size: 12px; line-height: 1.8; }
dialog { width: min(590px, calc(100% - 28px)); max-height: 85vh; overflow: auto; background: var(--panel); color: var(--ink); padding: 22px; border: 1px solid #3a4f6d; border-radius: 7px; box-shadow: 0 20px 80px #0008; }
dialog::backdrop { background: #020710b8; }
.dialog-header { display: flex; align-items: center; justify-content: space-between; gap: 15px; padding-bottom: 14px; margin-bottom: 16px; border-bottom: 1px solid var(--line); }
.dialog-header h2 { font-size: 18px; }
.close-dialog { width: 34px; height: 34px; border: 1px solid var(--line); border-radius: 4px; background: var(--raised); color: var(--muted); font-size: 22px; flex-shrink: 0; }
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.detail-item span { display: block; margin-bottom: 5px; color: var(--muted); font-size: 11px; }
.detail-item strong { color: #e3ecfa; font: 19px var(--mono); }
.detail-note { border-top: 1px solid var(--line); padding-top: 14px; margin: 18px 0 0; color: var(--muted); font-size: 12px; line-height: 1.8; }
.help-content p { color: #adbed4; font-size: 12px; line-height: 1.8; overflow-wrap: anywhere; }
.help-content h3 { margin: 18px 0 7px; font-size: 13px; color: #d5e0f1; }
.spinning { animation: spin 1.5s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (max-width: 1100px) {
  .sidebar { width: 172px; padding: 24px 10px; }
  main { margin-left: 172px; padding-inline: 18px; }
  .nav-item { font-size: 12px; }
  .filter-grid { grid-template-columns: 1fr 1fr; gap: 14px; }
  .strategy-steps { grid-template-columns: 1fr 1fr; }
  .hero-date { font-size: 11px; }
}
@media (max-width: 760px) {
  .sidebar { position: relative; width: 100%; padding: 12px; gap: 12px; border-right: 0; border-bottom: 1px solid var(--line); }
  .brand { font-size: 17px; }
  .brand small { display: none; }
  .nav-label, .sidebar-bottom { display: none; }
  .sidebar nav { display: flex; gap: 5px; overflow-x: auto; }
  .nav-item { flex-shrink: 0; width: auto; margin: 0; padding: 8px 10px; font-size: 12px; min-height: 36px; }
  .nav-number { font-size: 10px; }
  .nav-help { margin: 0; }
  main { margin: 0; padding: 0 12px 20px; }
  .topbar { height: 35px; }
  .hero { padding: 15px 0; align-items: start; }
  h1 { font-size: 21px; }
  .hero-date { max-width: 55%; font-size: 10px; }
  .hero-date small { font-size: 10px; }
  .section-heading, .results-header { padding: 12px; }
  .filter-grid { padding: 14px 12px; gap: 14px 10px; }
  .field label { font-size: 11px; }
  .primary-button, .secondary-button, .select-wrap select, .single-input, .range-input > div { min-height: 40px; height: 40px; }
  .live-controls, .filter-footer { padding-inline: 12px; }
  .live-controls { gap: 8px; }
  .metrics { grid-template-columns: 1fr 1fr; gap: 8px; margin: 10px 0; }
  .metric { padding: 11px 12px; }
  .metric strong { font-size: 25px; }
  .toolbar { padding: 0 12px 12px; flex-wrap: wrap; }
  .search { flex: 1; min-width: 140px; height: 38px; }
  .search input { width: 100%; }
  .segments { flex-shrink: 0; }
  .segment { padding-inline: 10px; }
  table { min-width: 720px; }
  .strategy-table { min-width: 850px; }
  th, td { padding-inline: 10px; }
  th:first-child, td:first-child { padding-left: 12px; }
  td { height: 46px; }
  .ratio-meter, .row-arrow { display: none; }
  .table-footer { padding: 10px 12px; flex-wrap: wrap; }
  .strategy-controls { padding: 13px 12px; gap: 10px; }
  .strategy-controls .field { flex: 1 0 100%; }
  .strategy-controls select { min-width: 0; }
  .strategy-rules { margin-inline: 12px; }
  .strategy-steps { gap: 10px; }
  .strategy-steps article { padding-left: 9px; }
  .strategy-steps p { font-size: 11px; }
  .strategy-explanation { padding-inline: 12px; }
  .scan-progress { padding: 10px 12px; }
}
@media (prefers-reduced-motion: reduce) { .spinning, .loading-ring { animation: none; } }
