:root{color-scheme:dark;--bg:#0c1118;--panel:#151c26;--line:#2b3747;--text:#e7edf5;--muted:#91a0b3;--blue:#438dd8;--red:#ef5350;--green:#26a69a}
.ma30{color:#ef72c9}.ma90{color:#8bc34a}.ma120{color:#ff8a65}.ma200{color:#66e0ff}.ma360{color:#b39ddb}
#customIndexView{height:auto;min-height:100%;padding-bottom:16px}
#customIndexNote{margin:0 0 10px;color:var(--muted);font-size:12px;line-height:1.7}
#customIndexScope{max-width:280px}
#customIndexView .index-date{display:flex;align-items:center;gap:6px;white-space:nowrap}
#customIndexCards{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:10px;margin-bottom:8px}
#customIndexCards>div{padding:12px;background:#151f2c;border:1px solid var(--line);border-radius:7px}
#customIndexCards small{display:block;color:var(--muted);margin-bottom:6px}
#customIndexCards strong{font-size:20px}
#customIndexReadout{min-height:30px;color:#9acbff;padding:6px 0}
#customIndexChart{width:100%;height:340px;min-height:340px;flex:none;background:#101720;border:1px solid var(--line);border-radius:8px}
.custom-index-table{overflow:auto;max-height:320px;min-height:100px;border:1px solid var(--line)}
.custom-index-table table{min-width:720px}
.custom-index-table tbody tr{cursor:pointer}
.custom-index-table tbody tr:focus{outline:1px solid #f5b942;outline-offset:-2px}
.custom-index-comparison{display:flex;align-items:center;justify-content:space-between;gap:8px;margin-bottom:8px;color:#f5b942;font-size:12px}
.custom-index-comparison button{flex-shrink:0}
.custom-index-table th button{padding:4px 0;border:0;background:transparent;font:inherit;font-weight:600;white-space:nowrap}
.custom-index-table th[aria-sort="ascending"] button,.custom-index-table th[aria-sort="descending"] button{color:#9acbff}
#customIndexView h3{font-size:14px;margin:12px 0 8px}
@media(max-width:760px){#customIndexCards{grid-template-columns:repeat(2,minmax(0,1fr))}#customIndexCards strong{font-size:18px}#customIndexScope{max-width:100%;min-width:150px}#customIndexChart{height:280px;min-height:280px}#customIndexView .index-date{flex:1;min-width:160px}#customIndexView .index-date input{min-width:0;width:100%}}
*{box-sizing:border-box}body{margin:0;background:var(--bg);color:var(--text);font:14px system-ui,"Microsoft YaHei",sans-serif}button,input,select{background:#1b2532;color:var(--text);border:1px solid #35445a;border-radius:6px;padding:9px}button{cursor:pointer}button:hover{border-color:#5798dc}button:disabled{opacity:.45;cursor:not-allowed}.hidden{display:none!important}
.login-screen{position:fixed;inset:0;display:grid;place-items:center;background:radial-gradient(circle at 50% 30%,#18314d,#090d13)}.login-card{width:min(360px,90vw);padding:30px;display:grid;gap:14px;background:rgba(20,28,39,.96);border:1px solid #35445a;border-radius:14px;box-shadow:0 20px 70px #0008}.login-card h1{margin:0}.login-card p{margin:0 0 10px;color:var(--muted)}.error{color:#ff7774;min-height:20px}
.favorite-dialog{width:min(520px,92vw);max-height:80vh;padding:0;background:#151d28;color:var(--text);border:1px solid #40516a;border-radius:12px;box-shadow:0 20px 70px #000b}.favorite-dialog::backdrop{background:#05080dbb}.favorite-dialog form{padding:18px}.dialog-head,.dialog-actions{display:flex;align-items:center;gap:8px}.dialog-head h2{margin:0;flex:1}.dialog-head button{font-size:22px;border:0;background:transparent}.dialog-actions{justify-content:flex-end;margin-top:16px}.favorite-choices{max-height:50vh;overflow:auto;display:grid;gap:8px}.choice-group{padding:10px;border:1px solid var(--line);border-radius:8px}.choice-group>b{display:block;margin-bottom:7px;color:#9acbff}.choice-list{display:grid;grid-template-columns:repeat(3,1fr);gap:6px}.choice-list label{display:flex;align-items:center;gap:6px;padding:7px;background:#1b2634;border-radius:5px}.choice-list input{accent-color:#438dd8}
.app{height:100vh;display:grid;grid-template:56px 1fr/220px 1fr;grid-template-areas:"header header" "aside main"}header{grid-area:header;display:flex;align-items:center;gap:14px;padding:0 16px;background:#121923;border-bottom:1px solid var(--line)}header strong{font-size:18px}header #currentTitle{color:#a9cbea;flex:1;min-width:120px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}header nav{display:flex;gap:4px}header nav button{padding:7px 11px;border-color:transparent;background:transparent}header nav button.active{background:#25486d;border-color:#438dd8}aside{grid-area:aside;padding:12px;display:flex;flex-direction:column;gap:9px;border-right:1px solid var(--line);min-width:0}aside input,aside select{width:100%}.instrument-list{overflow:auto;flex:1}.instrument{padding:10px;border-bottom:1px solid #202b39;cursor:pointer}.instrument:hover,.instrument.active{background:#1c2a3b}.instrument b{display:block}.instrument small{color:var(--muted);display:flex;justify-content:space-between;gap:8px;margin-top:4px}.instrument small span:first-child{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}main{grid-area:main;min-width:0;padding:12px;overflow:hidden}.view{display:none;height:100%;min-width:0}.view.active{display:flex;flex-direction:column}.toolbar{display:flex;align-items:center;gap:8px;flex-wrap:wrap}.toolbar>div{margin-right:auto}.toolbar b{display:block;font-size:18px}.toolbar small{color:var(--muted)}.controls{margin-bottom:10px}.controls input{max-width:160px}#message{min-height:30px;padding:7px 2px;color:#8ec5ff}.chart-wrap{position:relative;min-height:0;flex:1}#chart,.feature-chart{width:100%;background:#101720;border:1px solid var(--line);border-radius:8px}#chart{height:100%;touch-action:none}.chart-tooltip{position:fixed;z-index:20;pointer-events:none;padding:8px 10px;background:#0a0f16ee;border:1px solid #53657c;border-radius:6px;box-shadow:0 5px 20px #0009;font-size:12px;line-height:1.6;white-space:nowrap}.feature-chart{height:calc(100vh - 185px);min-height:420px}.legend{display:flex;gap:14px;flex-wrap:wrap;color:var(--muted);padding:8px}.ma5{color:#f5d547}.ma10{color:#ec75d8}.ma20{color:#4da3ff}.ma60{color:#c7d0dc}.icon-button{display:none}.summary-card{padding:10px;margin-bottom:10px;background:#151f2c;border:1px solid var(--line);border-radius:7px}.score-grid{display:grid;grid-template-columns:repeat(6,1fr);gap:8px;margin-bottom:10px}.score-card{padding:9px;background:#151f2c;border:1px solid var(--line);border-radius:7px}.score-card b{font-size:18px;display:block}.score-card small{color:var(--muted)}.anomaly-layout{display:grid;grid-template-columns:minmax(300px,38%) 1fr;gap:10px;min-height:0;flex:1}.event-table-wrap{overflow:auto;border:1px solid var(--line)}table{width:100%;border-collapse:collapse;font-size:12px}th,td{padding:7px;border-bottom:1px solid #263242;text-align:left}tbody tr{cursor:pointer}tbody tr:hover,tbody tr.active{background:#263b53}.anomaly-layout .feature-chart{height:100%;min-height:400px}.management-grid{display:grid;grid-template-columns:repeat(2,minmax(280px,520px));gap:16px}.manage-card{padding:18px;background:#151f2c;border:1px solid var(--line);border-radius:9px}.manage-card label{display:grid;grid-template-columns:90px 1fr;align-items:center;margin:10px 0}.manage-card button{margin:4px}.task-status{padding:10px 0;color:#8ec5ff}.progress-track{height:8px;margin-top:14px;background:#0b1017;border-radius:5px;overflow:hidden}.progress-track div{height:100%;width:0;background:#438dd8;transition:.2s}.manage-card pre{max-height:220px;overflow:auto;white-space:pre-wrap;color:#ff8d89}
@media(max-width:760px){.app{grid-template:92px 1fr/1fr;grid-template-areas:"header" "main"}header{height:92px;gap:8px;padding:6px 10px;flex-wrap:wrap}header strong{font-size:15px}header span{display:none}header nav{order:4;width:100%}header nav button{flex:1;padding:7px 4px}.icon-button{display:block}aside{position:fixed;z-index:5;top:92px;bottom:0;left:0;width:min(86vw,340px);background:#101720;transform:translateX(-102%);transition:.2s;box-shadow:12px 0 35px #0009}aside.open{transform:none}main{padding:8px}.toolbar>div{width:100%;margin:0}.toolbar button,.toolbar select{padding:8px 7px;flex:1}#chart{height:100%;min-height:400px}.feature-chart{height:calc(100vh - 255px);min-height:390px}.legend{font-size:11px;gap:8px}.score-grid{grid-template-columns:repeat(2,1fr)}.anomaly-layout{display:flex;flex-direction:column}.event-table-wrap{max-height:210px}.anomaly-layout .feature-chart{min-height:360px}.choice-list{grid-template-columns:repeat(2,1fr)}.management-grid{grid-template-columns:1fr;overflow:auto}.manage-card label{grid-template-columns:75px 1fr}}

/* Keep the anomaly report inside the remaining viewport height on desktop. */
@media(min-width:761px){
  .app{height:100dvh;grid-template-rows:56px minmax(0,1fr)}
  #anomalyView{min-height:0;overflow:hidden}
  .anomaly-layout{grid-template-columns:minmax(300px,38%) minmax(0,1fr);grid-template-rows:minmax(0,1fr);overflow:hidden}
  .event-table-wrap{min-height:0;overflow:auto}
  .anomaly-layout .feature-chart{display:block;width:100%;height:100%;min-width:0;min-height:0}
}

.schedule-status{margin:10px 0;padding:10px;background:#101923;border:1px solid var(--line);border-radius:6px;color:#9fc8f3}
.statistics-cards{display:grid;grid-template-columns:repeat(6,minmax(120px,1fr));gap:8px;margin-bottom:10px}.statistics-card{padding:10px;background:#151f2c;border:1px solid var(--line);border-radius:7px}.statistics-card b{display:block;font-size:20px;margin-bottom:3px}.statistics-card small{color:var(--muted)}.statistics-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:10px;padding-bottom:18px}.statistics-grid article{min-width:0;padding:10px;background:#151f2c;border:1px solid var(--line);border-radius:8px}.statistics-grid h3{margin:0 0 8px;font-size:14px}.statistics-grid canvas{display:block;width:100%;height:260px;background:#101720;border-radius:6px}
.correlation-table-wrap{min-height:180px;overflow:auto;border:1px solid var(--line);flex:1}#correlationView .controls span{color:var(--muted);padding:8px}#correlationChart{width:100%;height:280px;min-height:220px;background:#101720;border:1px solid var(--line);border-radius:8px;margin-bottom:10px}
.more-nav-dialog{width:min(360px,88vw);padding:18px;background:#151d28;color:var(--text);border:1px solid #40516a;border-radius:12px}.more-nav-dialog #moreNavChoices{display:grid;gap:8px}.more-nav-dialog #moreNavChoices button{width:100%;text-align:left}.more-nav-button{display:none}
#sentimentView .fourier-chart{height:280px;min-height:280px}
.backtest-page-tabs,.portfolio-tabs{display:flex;gap:6px;margin-bottom:8px}.backtest-page-tabs button.active,.portfolio-tabs button.active{background:#25486d;border-color:#438dd8}.backtest-panel{min-height:0;flex:1}.portfolio-layout{display:grid;grid-template-columns:minmax(360px,42%) minmax(0,1fr);gap:10px;height:calc(100vh - 250px);min-height:430px}.portfolio-list{display:flex;flex-direction:column;min-width:0;min-height:0}.portfolio-table-wrap{overflow:auto;border:1px solid var(--line);flex:1}.portfolio-layout .feature-chart{height:100%;min-height:430px}

@media(max-width:760px){header nav button.more-nav-item{display:none}header nav .more-nav-button{display:block}}
@media(max-width:760px){#sentimentView .fourier-chart{height:260px;min-height:260px}}
@media(max-width:760px){.portfolio-layout{display:flex;flex-direction:column;height:auto}.portfolio-table-wrap{max-height:260px}.portfolio-layout .feature-chart{height:430px;min-height:430px}.backtest-page-tabs button,.portfolio-tabs button{flex:1}}
@media(max-width:760px){.statistics-cards{grid-template-columns:repeat(2,1fr)}.statistics-grid{grid-template-columns:1fr}.statistics-grid canvas{height:240px}#statisticsView{overflow:visible;padding-bottom:18px}}

@media(max-width:760px){
  input,select,textarea{font-size:16px}
  .login-card input{font-size:16px;min-height:44px}
  .app{height:100dvh}
  main{overflow-y:auto;overflow-x:hidden;-webkit-overflow-scrolling:touch}
  .view{height:auto;min-height:100%}
  #marketView{height:100%;min-height:0;overflow:hidden}
  #sentimentView,#backtestView,#anomalyView,#dataView{overflow:visible;padding-bottom:18px}
  #sentimentView .feature-chart{height:390px;min-height:390px;flex:none}
  header strong{flex:none}
  header #currentTitle{display:block;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;flex:1}
  header #logoutButton{flex:none;margin-left:auto}
}

/* Desktop and landscape screens share one content-height policy: charts use
   the available viewport height, while minimum readable heights make the main
   area scroll only when the complete result no longer fits. */
@media(min-width:761px), (orientation:landscape){
  main{overflow-x:hidden;overflow-y:auto;-webkit-overflow-scrolling:touch}
  #sentimentView,#backtestView{height:auto;min-height:100%;overflow:visible;padding-bottom:18px}
  #sentimentView .feature-chart{height:calc(100dvh - 185px);min-height:420px;flex:none}
  #sentimentView .fourier-chart{height:280px;min-height:280px}
  #backtestView .backtest-panel{flex:none;min-height:0}
  #backtestView #backtestChart{height:calc(100dvh - 245px);min-height:420px}
}

#screenFields{border:1px solid var(--line);padding:12px;min-width:0}.screen-line,.screen-periods{display:flex;flex-wrap:wrap;gap:12px;align-items:center}.screen-line{margin:10px 0}.screen-line label{display:inline-flex;align-items:center;gap:5px}.screen-line input[type=number]{width:90px}.screen-line input[type=checkbox],.screen-line input[type=radio]{width:auto}.screen-note{font-size:12px;color:var(--muted)}.screen-results{overflow:auto;max-height:60vh;min-height:100px}.screen-results td,.screen-results th{white-space:nowrap}#stockScreenView{overflow:auto}#screenStop{align-self:flex-start;margin-top:10px}
.manage-subtitle{margin-top:20px;padding-top:16px;border-top:1px solid var(--line)}

#industryView{min-height:0;overflow:hidden}.industry-heading{display:flex;align-items:flex-end;justify-content:space-between;gap:16px;margin-bottom:8px}.industry-heading h2{margin:0 0 4px}.industry-heading p{margin:0;color:var(--muted)}#industryCurrent{color:#9acbff}.industry-status{min-height:34px;padding:7px 0;color:var(--muted)}.industry-table-wrap{min-height:0;overflow:auto;border:1px solid var(--line);border-radius:8px}.industry-table{min-width:880px;table-layout:fixed}.industry-table thead{position:sticky;top:0;z-index:2;background:#182230}.industry-table th:first-child{width:138px}.industry-table th,.industry-table td{padding:6px}.industry-table tbody th{background:#111923;text-align:left}.industry-table tbody th span{display:block;color:#8dbce9;font-size:11px;font-weight:500}.industry-table tbody th b{display:block;font-size:13px;overflow-wrap:anywhere}.industry-table tr.industry-group-start>*{border-top:2px solid #40536c}.industry-slot-control{position:relative}.industry-slot{display:flex;align-items:center;justify-content:center;gap:7px;width:100%;min-height:42px;padding:5px 8px;border-radius:6px;overflow:hidden}.industry-slot b{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.industry-slot small{color:var(--muted);flex:none}.industry-slot.empty{color:#738399;background:#141d28;border-style:dashed}.industry-slot.filled{padding-right:29px;background:#1d3044;border-color:#3c6b98}.industry-slot.filled:hover{background:#25415d}.industry-slot-clear{position:absolute;top:5px;right:4px;width:28px;height:32px;padding:0;border:0;background:transparent;color:#98a8ba;font-size:18px}.industry-slot-clear:hover{color:#ff8d89;background:#39242a}
@media(max-width:760px){#industryView{overflow:visible}.industry-heading{align-items:flex-start;flex-direction:column}.industry-table-wrap{overflow:auto;max-height:none}.industry-table th:first-child{width:114px}.industry-slot{min-width:120px}}

#simulationView{height:auto;min-height:100%;padding-bottom:18px;overflow:visible}
.simulation-note{margin:0 0 8px;color:var(--muted)}
.simulation-title{font-size:17px;font-weight:700;color:#9acbff;margin-bottom:8px}
.simulation-stats{display:flex;flex-wrap:wrap;gap:14px;margin-bottom:8px;color:#d7e2ee}
.simulation-actions{margin-bottom:8px}
.simulation-profit{padding:9px 11px;margin-bottom:9px;background:#18212d;border:1px solid #314158;border-radius:6px;font-size:16px;font-weight:700;color:var(--red)}
#simulationChart{display:block;width:100%;height:560px;min-height:420px;background:#101720;border:1px solid var(--line);border-radius:8px}
.simulation-trade-dialog{width:min(980px,94vw);max-height:82vh;padding:14px;background:#151d28;color:var(--text);border:1px solid #40516a;border-radius:10px}
.simulation-trade-dialog::backdrop{background:#05080dbb}
.simulation-trade-dialog .dialog-head{margin-bottom:10px}.simulation-trade-dialog .dialog-head h2{font-size:18px}
.simulation-trades{max-height:66vh;overflow:auto;border:1px solid var(--line)}
.simulation-trades th{position:sticky;top:0;background:#182230;z-index:1}
#simulationAuto.running{color:#ffcc80;border-color:#c78b3d}
@media(max-width:760px){.simulation-setup label,.simulation-actions label{display:flex;align-items:center;gap:5px;flex:1 1 145px}.simulation-setup select,.simulation-actions select{min-width:0;flex:1}#simulationChart{height:440px;min-height:380px}.simulation-profit{font-size:14px;line-height:1.6}.simulation-trades{max-height:220px}}
#marketView,#simulationView{height:100%;min-height:650px;overflow:visible}
@media(min-width:761px){#simulationChart{height:auto;min-height:360px;flex:1}}

/* On touch screens, vertical drags scroll the page while horizontal drags
   remain available to the interactive market chart. */
#chart{touch-action:pan-y}

#valuationView{height:auto;min-height:100%;overflow:visible;padding-bottom:18px}
.valuation-controls>label{display:flex;align-items:center;gap:6px;white-space:nowrap}
.valuation-tabs{display:flex;gap:6px}
.valuation-zoom-controls{display:flex;gap:5px;margin-left:0!important}
.valuation-zoom-controls button{padding:7px 10px}
.valuation-tabs button.active{background:#25486d;border-color:#438dd8}
.valuation-readout{min-height:30px;padding:4px 2px;color:#9acbff}
#valuationChart,#valuationComparisonChart{display:block;width:100%;background:#101720;border:1px solid var(--line);border-radius:8px;touch-action:pan-y;user-select:none;-webkit-user-select:none}
#valuationChart{height:52dvh;min-height:360px}
#valuationComparisonChart{height:34dvh;min-height:260px}
.valuation-comparison-title{padding:12px 3px 6px;color:#9acbff;font-weight:600}
@media(max-width:760px){.valuation-tabs{width:100%}.valuation-tabs button{flex:1}.valuation-controls>label{flex:1 1 150px}.valuation-controls>label select{min-width:0;flex:1}.valuation-zoom-controls{width:100%}.valuation-zoom-controls button{flex:1}#valuationChart{height:390px;min-height:340px}#valuationComparisonChart{height:300px;min-height:260px}}
