/* Shared Single / Batch mode switch; keep every existing control and ID. */
#research-view{position:relative}
#test-top-row{display:flex;align-items:center;gap:8px;flex:0 0 auto;margin-bottom:10px}
#test-top-row .test-mode-tabs{display:flex;gap:4px;padding:5px;border:1px solid var(--line);border-radius:10px;background:var(--surface);margin:0;width:max-content;max-width:100%;flex:0 1 auto}
#test-source-toggle{min-height:40px;padding:7px 12px;border:1px solid var(--line);border-radius:7px;background:var(--surface);font-weight:700;white-space:nowrap}
#test-source-toggle[aria-expanded="true"]{border-color:var(--green);color:var(--green)}
#test-source-panel[hidden]{display:none!important}
#test-source-panel{position:absolute;top:52px;left:0;z-index:35;width:min(480px,100%);max-height:min(70vh,560px);overflow:auto;padding:12px;border:1px solid var(--line);border-radius:10px;background:var(--surface);box-shadow:0 18px 40px #0005}
#test-source-panel header{display:flex;justify-content:space-between;align-items:start;gap:10px}
#test-source-panel header small{display:block;color:var(--muted);margin-top:3px}
#test-source-close{min-width:44px;min-height:44px}
#test-source-panel #batch-library{padding:6px 0}
#test-source-panel #test-source-status{font-size:12px;color:var(--muted)}
.test-mode-tabs button{min-height:40px;border:1px solid transparent;border-radius:7px;background:transparent;color:var(--muted);padding:7px 20px;font-weight:700}
.test-mode-tabs button[aria-selected="true"]{background:var(--mint);border-color:var(--green);color:var(--green)}
#batch-test-panel[hidden],#single-test-panel[hidden]{display:none!important}
#batch-test-panel>#batch-settings{margin:0}
#batch-settings>summary{display:none}
#batch-test-panel .batch-table-wrap{overflow:auto;max-height:min(38vh,390px)}
#batch-library{display:flex;align-items:flex-end;gap:10px;flex-wrap:wrap}
#batch-library label{flex:1 1 190px;min-width:0}
#batch-library-list{max-height:80px;width:100%}
#batch-library-note{flex-basis:100%;margin:0}
#batch-import-details>summary{cursor:pointer;font-weight:700;padding:7px 2px}
body.test-mode[data-test-mode="batch"] #app-view[hidden],body.test-mode[data-test-mode="batch"] #research-view[hidden]{display:none!important}
body.test-mode[data-test-mode="batch"] #app-view{height:100dvh;overflow:hidden}
body.test-mode[data-test-mode="batch"] #app-view main{height:100dvh;min-width:0;display:flex;flex-direction:column;overflow:hidden}
body.test-mode[data-test-mode="batch"] #app-view .topbar{flex:0 0 auto}
body.test-mode[data-test-mode="batch"] #app-view .workspace{max-width:none;width:100%;min-height:0;flex:1;margin:0;padding:8px 12px;display:flex;flex-direction:column;overflow:hidden}
body.test-mode[data-test-mode="batch"] #research-view{min-height:0;flex:1;display:flex;flex-direction:column;overflow:hidden}
body.test-mode[data-test-mode="batch"] #research-view>.page-heading{display:none}
body.test-mode[data-test-mode="batch"] #batch-test-panel{min-height:0;flex:1;display:grid;grid-template-columns:minmax(210px,245px) minmax(0,1fr);gap:10px;overflow:hidden}
body.test-mode[data-test-mode="batch"] #batch-settings{min-width:0;min-height:0;overflow:auto;border:1px solid var(--line);border-radius:10px;background:var(--surface)}
body.test-mode[data-test-mode="batch"] #batch-settings>.panel{margin:0;padding:10px;border:0;background:transparent;box-shadow:none}
body.test-mode[data-test-mode="batch"] #batch-test-panel>.panel{min-width:0;min-height:0;margin:0;padding:10px}
body.test-mode[data-test-mode="batch"] #batch-test-panel>.panel:first-child{overflow:auto}
body.test-mode[data-test-mode="batch"] #batch-test-panel>.panel[aria-labelledby="batch-title"]{display:flex;flex-direction:column;overflow:hidden}
body.test-mode[data-test-mode="batch"] #batch-test-panel>.panel[aria-labelledby="batch-title"]>.panel-heading{flex:0 0 auto;margin-bottom:3px}
body.test-mode[data-test-mode="batch"] #batch-import-details{flex:0 0 auto;max-height:35vh;overflow:auto}
body.test-mode[data-test-mode="batch"] #batch-import-details:not([open]){max-height:none;overflow:visible}
body.test-mode[data-test-mode="batch"] #batch-test-panel .batch-toolbar{flex:0 0 auto;display:flex;flex-wrap:wrap;gap:5px}
body.test-mode[data-test-mode="batch"] #batch-more{display:block;position:relative;flex:0 0 auto}
body.test-mode[data-test-mode="batch"] #batch-more>summary{display:block;cursor:pointer;min-height:44px;padding:10px;border:1px solid var(--line);border-radius:6px;font-weight:700}
body.test-mode[data-test-mode="batch"] #batch-more:not([open])>.batch-more-content{display:none!important}
body.test-mode[data-test-mode="batch"] #batch-more[open]>.batch-more-content{position:absolute;top:calc(100% + 4px);left:0;width:min(390px,calc(100vw - 42px));max-height:min(44vh,340px);overflow:auto;display:flex;flex-direction:column;gap:8px;padding:10px;border:1px solid var(--line);border-radius:8px;background:var(--surface);box-shadow:0 14px 32px #0003;z-index:25}
body.test-mode[data-test-mode="batch"] #batch-assumptions{flex:0 0 auto;font-size:11px}
body.test-mode[data-test-mode="batch"] #batch-assumptions>summary{cursor:pointer;padding:2px 0}
body.test-mode[data-test-mode="batch"] #batch-test-panel .batch-table-wrap{min-height:120px;flex:1;max-height:none;overflow:auto}
body.test-mode[data-test-mode="batch"] #batch-scope-retry[hidden]{display:none!important}
body.test-mode[data-test-mode="batch"] #batch-run-reason.batch-visually-hidden{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip-path:inset(50%);white-space:nowrap;border:0}
@media(max-width:900px){
  body.test-mode[data-test-mode="batch"] #batch-test-panel{position:relative;grid-template-columns:minmax(0,1fr);grid-template-rows:44px minmax(0,1fr);padding-bottom:10px}
  body.test-mode[data-test-mode="batch"] #batch-settings{height:44px;overflow:visible}
  body.test-mode[data-test-mode="batch"] #batch-settings>summary{display:block;cursor:pointer;padding:11px;font-weight:700}
  body.test-mode[data-test-mode="batch"] #batch-settings[open]{position:absolute;inset:0;height:auto;max-height:100%;overflow:auto;z-index:15;box-shadow:0 14px 36px #0003}
  body.test-mode[data-test-mode="batch"] #batch-settings[open]>summary{position:sticky;top:0;background:var(--surface);z-index:2}
  body.test-mode[data-test-mode="batch"] #batch-more{display:block;width:100%}
  body.test-mode[data-test-mode="batch"] #batch-more>summary{display:block;cursor:pointer;padding:8px 3px;font-weight:700}
  body.test-mode[data-test-mode="batch"] #batch-more[open]{max-height:none;overflow:visible}
  body.test-mode[data-test-mode="batch"] #batch-more[open]>.batch-more-content{width:100%;max-height:min(32vh,210px)}
  body.test-mode[data-test-mode="batch"] #batch-test-panel .batch-toolbar{flex-direction:column;flex-wrap:nowrap;align-items:stretch}
  body.test-mode[data-test-mode="batch"] #batch-run,body.test-mode[data-test-mode="batch"] #batch-more{flex:0 0 auto;max-width:100%}
  body.test-mode[data-test-mode="batch"] #batch-run{width:100%;height:44px}
  body.test-mode[data-test-mode="batch"] #batch-status{margin:3px 0;padding:5px;max-height:90px;overflow-wrap:anywhere}
  body.test-mode[data-test-mode="batch"] #batch-errors:empty{display:none}
  body.test-mode[data-test-mode="batch"] .batch-table-wrap table{min-width:1100px;table-layout:auto}
  body.test-mode[data-test-mode="batch"] .batch-table-wrap th,body.test-mode[data-test-mode="batch"] #batch-results td{white-space:nowrap;overflow-wrap:normal}
  body.test-mode[data-test-mode="batch"] #batch-results td{max-width:none}
  body.test-mode[data-test-mode="batch"] #batch-results td:first-child{min-width:170px}
  body.test-mode[data-test-mode="batch"] #batch-results td:nth-child(2){min-width:170px}
  body.test-mode[data-test-mode="batch"] #batch-results td:last-child{white-space:normal;overflow-wrap:anywhere;max-width:280px;min-width:170px}
}
@media(max-width:600px){
  #research-view>.test-mode-tabs{width:100%}.test-mode-tabs button{flex:1;min-width:0;padding:8px 11px}
  body.test-mode .sidebar{display:flex;flex-direction:column;align-items:stretch;gap:6px;padding:8px 12px 4px}
  body.test-mode .sidebar .brand.compact{flex-direction:row;align-items:center;gap:6px;width:max-content;min-height:29px;font-size:12px}
  body.test-mode .sidebar .brand.compact img{width:65px}
  body.test-mode .sidebar nav[data-workspace-nav="shared"]{margin:0;max-height:none;width:100%;gap:3px}
  body.test-mode .sidebar nav[data-workspace-nav="shared"]>.nav{font-size:12px;font-weight:600;min-height:40px;padding:7px 1px}
  body.test-mode #app-view .topbar{display:none}
  body.test-mode[data-test-mode="batch"] #batch-test-panel{padding-bottom:18px}
  body.test-mode[data-test-mode="batch"] #batch-test-panel .batch-table-wrap{overflow-y:auto;overflow-x:hidden}
  body.test-mode[data-test-mode="batch"] .batch-table-wrap table{display:block;min-width:0;width:100%;table-layout:auto}
  body.test-mode[data-test-mode="batch"] .batch-table-wrap thead{display:none}
  body.test-mode[data-test-mode="batch"] .batch-table-wrap tbody{display:grid;gap:8px;min-width:0}
  body.test-mode[data-test-mode="batch"] #batch-results tr{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:3px 9px;padding:10px;border:1px solid var(--line);border-radius:9px;background:var(--soft);min-width:0}
  body.test-mode[data-test-mode="batch"] #batch-results td,body.test-mode[data-test-mode="batch"] #batch-results td:first-child,body.test-mode[data-test-mode="batch"] #batch-results td:nth-child(2),body.test-mode[data-test-mode="batch"] #batch-results td:last-child{display:block;min-width:0;max-width:none;padding:3px;white-space:normal;overflow-wrap:anywhere;font-size:12px}
  body.test-mode[data-test-mode="batch"] #batch-results td::before{display:block;margin-bottom:2px;font-size:10px;color:var(--muted);font-weight:700}
  body.test-mode[data-test-mode="batch"] #batch-results td:nth-child(1)::before{content:'Source'}
  body.test-mode[data-test-mode="batch"] #batch-results td:nth-child(2)::before{content:'Strategy'}
  body.test-mode[data-test-mode="batch"] #batch-results td:nth-child(3)::before{content:'Status'}
  body.test-mode[data-test-mode="batch"] #batch-results td:nth-child(4)::before{content:'Net P&L'}
  body.test-mode[data-test-mode="batch"] #batch-results td:nth-child(5)::before{content:'Trades'}
  body.test-mode[data-test-mode="batch"] #batch-results td:nth-child(6)::before{content:'Win %'}
  body.test-mode[data-test-mode="batch"] #batch-results td:nth-child(7)::before{content:'Max DD'}
  body.test-mode[data-test-mode="batch"] #batch-results td:nth-child(8)::before{content:'Unavailable'}
  body.test-mode[data-test-mode="batch"] #batch-results td:nth-child(9)::before{content:'Errors'}
  body.test-mode[data-test-mode="batch"] #batch-results td:nth-child(2),body.test-mode[data-test-mode="batch"] #batch-results td:nth-child(9){grid-column:1/-1}
}

/* Single keeps the page fixed; only the active work area scrolls. */
body.test-mode[data-test-mode="single"] #app-view{height:100dvh;overflow:hidden}
body.test-mode[data-test-mode="single"] #app-view main{height:100dvh;min-width:0;display:flex;flex-direction:column;overflow:hidden}
body.test-mode[data-test-mode="single"] #app-view .topbar{flex:0 0 auto}
body.test-mode[data-test-mode="single"] #app-view .workspace{max-width:none;width:100%;min-height:0;flex:1;margin:0;padding:8px 12px;display:flex;flex-direction:column;overflow:hidden}
body.test-mode[data-test-mode="single"] #research-view{min-height:0;flex:1;display:flex;flex-direction:column;overflow:hidden}
body.test-mode[data-test-mode="single"] #research-view>.page-heading{display:none}
body.test-mode[data-test-mode="single"] #single-test-panel{min-height:0;flex:1;display:flex;flex-direction:column;gap:8px;overflow:hidden}
#single-view-tabs{display:flex;gap:4px;flex:0 0 auto;border-bottom:1px solid var(--line)}
#single-view-tabs button{flex:1;min-width:0;min-height:40px;padding:5px;border:0;background:transparent;color:var(--muted);font-weight:700}
#single-view-tabs button[aria-selected="true"]{color:var(--green);border-bottom:2px solid var(--green)}
#single-queue[hidden]{display:none!important}
#single-queue{margin:0;padding:12px 14px;flex:0 0 auto;color:var(--foreground);background:#1e2b3b;border:1px solid #486486;border-radius:8px;font-size:15px;line-height:1.45;overflow-wrap:anywhere}
#single-test-panel[data-single-view="setup"]>#single-queue,#single-test-panel[data-single-view="trades"]>#single-queue{display:none!important}
#single-test-panel[data-queue-state="queued"][data-single-view="results"]>.metrics{display:none}
#single-test-panel[data-queue-state="queued"][data-single-view="results"] #run-status{display:none}
#single-test-panel>.panel,#single-test-panel>.metrics,#single-test-panel>.desk-grid{margin:0;min-width:0}
#single-test-panel[data-single-view="setup"]>.metrics,#single-test-panel[data-single-view="setup"]>.results-panel,#single-test-panel[data-single-view="setup"]>.history-panel,
#single-test-panel[data-single-view="results"]>#single-strategy,#single-test-panel[data-single-view="results"]>.panel[aria-label="Local historical coverage"],#single-test-panel[data-single-view="results"]>.results-panel,#single-test-panel[data-single-view="results"]>.history-panel,
#single-test-panel[data-single-view="trades"]>#single-strategy,#single-test-panel[data-single-view="trades"]>.panel[aria-label="Local historical coverage"],#single-test-panel[data-single-view="trades"]>.panel[aria-label="Silver contract chart"],#single-test-panel[data-single-view="trades"]>.metrics,#single-test-panel[data-single-view="trades"]>.desk-grid{display:none!important}
#single-test-panel[data-single-view="setup"]>.panel[aria-label="Silver contract chart"]{display:none}
#single-test-panel[data-single-view="setup"]>#single-strategy{flex:0 1 auto;max-height:150px;overflow:auto;padding:8px 12px}
#single-test-panel[data-single-view="setup"]>#single-strategy h2,#single-test-panel[data-single-view="setup"]>#single-strategy h3,#single-test-panel[data-single-view="setup"]>#single-strategy p{margin:2px 0}
#single-test-panel[data-single-view="setup"]>.panel[aria-label="Local historical coverage"]{flex:0 1 auto;max-height:95px;overflow:auto;padding:8px 12px}
#single-test-panel[data-single-view="setup"]>.desk-grid{display:block;flex:1;min-height:0;overflow:hidden}
#single-test-panel[data-single-view="setup"] .analysis-column{display:none}
#single-test-panel[data-single-view="setup"] .run-config{height:100%;overflow:auto;margin:0}
#single-test-panel[data-single-view="results"]>.metrics{flex:0 0 auto}
#single-test-panel[data-single-view="results"]>.panel[aria-label="Silver contract chart"]{flex:0 0 auto;padding:6px 10px}
#single-test-panel[data-single-view="results"]>.desk-grid{display:block;flex:1;min-height:0;overflow:auto}
#single-test-panel[data-single-view="results"] .run-config{display:none}
#single-test-panel[data-single-view="results"] .analysis-column{display:flex;flex-direction:column;gap:8px;min-width:0}
#single-test-panel[data-single-view="results"] .analysis-column>.panel{margin:0}
#single-test-panel[data-single-view="trades"]>.results-panel{display:flex;flex-direction:column;flex:1;min-height:0;overflow:hidden}
#single-test-panel[data-single-view="trades"]>.results-panel .table-wrap{flex:1;min-height:0;overflow:auto}
#single-test-panel[data-single-view="trades"]>.history-panel{flex:0 0 auto;max-height:130px;overflow:auto}
@media(max-width:600px){
  #single-view-tabs button{font-size:11px}
  #single-test-panel[data-single-view="results"]>.metrics{margin:0}
  #single-test-panel[data-single-view="results"]>.metrics article{padding:6px}
  #single-test-panel[data-single-view="results"] .analysis-column>.panel{padding:8px}
  #single-test-panel[data-single-view="results"] #equity-chart{min-height:120px;height:22vh}
  #single-test-panel[data-single-view="trades"]>.history-panel{max-height:105px}
  #single-test-panel[data-single-view="setup"] .run-config{padding-bottom:64px}
  #single-test-panel[data-single-view="setup"] #run-btn{position:fixed;left:12px;right:12px;bottom:10px;z-index:20;width:calc(100% - 24px);min-height:44px;box-shadow:0 0 0 4px var(--surface)}
}
