
#tqqq-atlas { position:relative; display:grid; gap:calc(var(--font-size-base)*1); color:var(--foreground); }
#tqqq-atlas .heading { display:grid; gap:calc(var(--font-size-base)*.5); }
#tqqq-atlas .panel { display:grid; gap:calc(var(--font-size-base)*.25); min-width:0; }
#tqqq-atlas .panel-head { display:flex; flex-wrap:wrap; gap:calc(var(--font-size-base)*.5); align-items:baseline; justify-content:space-between; }
#tqqq-atlas .chart { width:100%; display:block; overflow:visible; }
#tqqq-atlas .chart text { fill:var(--foreground); font-size:12px; font-weight:400; }
#tqqq-atlas .chart .domain,#tqqq-atlas .chart .tick line { stroke:var(--border); }
#tqqq-atlas .chart .grid line { stroke:var(--border); opacity:.55; }
#tqqq-atlas .chart .grid .domain { display:none; }
#tqqq-atlas .chart .series { fill:none; stroke-width:1.65; }
#tqqq-atlas .chart .frame { fill:none; stroke:var(--border); stroke-width:1; }
#tqqq-atlas .legend { display:flex; flex-wrap:wrap; gap:calc(var(--font-size-base)*1); }
#tqqq-atlas .legend button { color:var(--foreground); background:transparent; border:0; padding:0; font:inherit; display:inline-flex; align-items:center; gap:.4em; }
#tqqq-atlas .legend button[aria-pressed="false"] { opacity:.4; }
#tqqq-atlas .legend .swatch { width:10px; height:10px; display:inline-block; }
#tqqq-atlas .tooltip { position:absolute; display:none; z-index:10; pointer-events:none; background:var(--popover); color:var(--popover-foreground); padding:calc(var(--font-size-base)*.75); max-width:calc(100% - 16px); }
#tqqq-atlas .tooltip .tip-row { display:flex; justify-content:space-between; gap:1em; }
#tqqq-atlas .selected { display:grid; gap:calc(var(--font-size-base)*.5); }
#tqqq-atlas .selected dl { margin:0; display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:calc(var(--font-size-base)*.5); }
#tqqq-atlas .selected dt { color:var(--muted-foreground); }
#tqqq-atlas .selected dd { margin:0; font-weight:500; font-variant-numeric:tabular-nums; }
#tqqq-atlas details { min-width:0; }
#tqqq-atlas summary { padding:calc(var(--font-size-base)*.35) 0; }
#tqqq-atlas details[open] > summary { margin-bottom:calc(var(--font-size-base)*.5); }
#tqqq-atlas .detail-content { display:grid; gap:calc(var(--font-size-base)*.75); }
#tqqq-atlas .trade-table td,#tqqq-atlas .trade-table th { white-space:nowrap; }
#tqqq-atlas .caption { color:var(--muted-foreground); }
#tqqq-atlas strong { font-weight:500; }
#tqqq-atlas .status { min-width:0; overflow-wrap:anywhere; }
@media(max-width:480px) { #tqqq-atlas .selected dl { grid-template-columns:repeat(2,minmax(0,1fr)); } }

/* Standalone dashboard styles; the analysis inherits the existing product palette. */
.dashboard-tabs { display:flex; gap:8px; align-items:center; padding:12px 24px; border-bottom:1px solid var(--border); background:var(--bg); position:sticky; top:0; z-index:20; }
.dashboard-tabs button { border:1px solid var(--border); border-radius:8px; background:var(--bg2); color:var(--text2); padding:10px 18px; min-height:44px; font:inherit; font-weight:600; cursor:pointer; }
.dashboard-tabs button[aria-selected="true"] { background:var(--blue); border-color:var(--blue); color:var(--bg); }
#research-section { max-width:1280px; margin:0 auto; padding:24px; }
#research-section[hidden] { display:none; }
#research-section .research-loading { padding:32px 0; color:var(--text2); }
body[data-dashboard-tab="research"] > .chart-section,
body[data-dashboard-tab="research"] > #main-chart,
body[data-dashboard-tab="research"] > .hint,
body[data-dashboard-tab="research"] > .bottom-section,
body[data-dashboard-tab="research"] > .rules-section,
body[data-dashboard-tab="research"] .header .date-range-group,
body[data-dashboard-tab="research"] .header .metrics-row,
body[data-dashboard-tab="research"] .header .live-portfolio,
body[data-dashboard-tab="research"] .header .header-sub { display:none; }
#tqqq-atlas { --font-size-base:14px; --foreground:var(--text); --muted-foreground:var(--text2); --card:var(--bg2); --card-foreground:var(--text); --popover:var(--bg3); --popover-foreground:var(--text); --viz-series-1:var(--blue); --viz-series-2:var(--green); --viz-series-3:var(--red); --viz-series-4:var(--purple); font-size:14px; }
#tqqq-atlas h2 { font-size:22px; font-weight:650; }
#tqqq-atlas h3 { font-size:16px; font-weight:600; }
#tqqq-atlas .text-small { font-size:12px; }
#tqqq-atlas .tabular-nums { font-variant-numeric:tabular-nums; }
#tqqq-atlas .viz-controls { display:flex; flex-wrap:wrap; align-items:flex-end; gap:12px; }
#tqqq-atlas .form-label { display:grid; gap:6px; flex:1 1 240px; min-width:0; font-weight:500; }
#tqqq-atlas .form-select { width:100%; min-width:0; padding:10px 12px; min-height:44px; color:var(--text); border:1px solid var(--border); border-radius:8px; background:var(--bg2); font:inherit; color-scheme:dark; }
#tqqq-atlas .card { background:var(--bg2); border:1px solid var(--border); border-radius:12px; padding:16px; }
#tqqq-atlas .btn { font:inherit; border:1px solid var(--border); background:var(--bg3); color:var(--text); border-radius:6px; min-height:40px; padding:8px 10px; cursor:pointer; }
#tqqq-atlas .btn-ghost { background:transparent; border-color:transparent; color:var(--blue); }
#tqqq-atlas .cursor-interaction { cursor:pointer; }
#tqqq-atlas .table-responsive { overflow-x:auto; -webkit-overflow-scrolling:touch; }
#tqqq-atlas .table { border-collapse:collapse; width:100%; font-size:13px; }
#tqqq-atlas .table td,#tqqq-atlas .table th { padding:10px 12px; border-bottom:1px solid var(--border); text-align:left; }
#tqqq-atlas .table th { background:var(--bg2); color:var(--text2); }
#tqqq-atlas .table .text-end { text-align:right; font-variant-numeric:tabular-nums; }
#tqqq-atlas .text-nowrap { white-space:nowrap; }
#tqqq-atlas summary { min-height:44px; display:list-item; padding:12px 0; font-weight:550; }
#tqqq-atlas .legend button { min-height:40px; }
#tqqq-atlas .recent-case { display:grid; gap:12px; padding:18px; background:var(--bg2); border-left:3px solid var(--blue); border-radius:0 10px 10px 0; }
#tqqq-atlas .recent-case:empty { display:none; }
#tqqq-atlas .recent-heading { display:flex; flex-wrap:wrap; justify-content:space-between; gap:6px; }
#tqqq-atlas .recent-flow { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:12px; }
#tqqq-atlas .recent-step { display:grid; gap:4px; }
#tqqq-atlas .recent-step strong { font-size:20px; }
#tqqq-atlas .recent-step .event-type { font-weight:600; }
#tqqq-atlas .recent-result { padding-top:8px; border-top:1px solid var(--border); font-weight:550; }
#tqqq-atlas .recent-note { font-size:12px; color:var(--text2); }
@media(max-width:640px) {
  .dashboard-tabs { padding:8px 12px; }
  .dashboard-tabs button { flex:1; padding:10px 8px; }
  #research-section { padding:18px 12px; }
  #tqqq-atlas .form-select { font-size:16px; }
  #tqqq-atlas .recent-flow { grid-template-columns:1fr; }
  #tqqq-atlas .recent-step { grid-template-columns:1fr auto; align-items:center; gap:4px 12px; }
  #tqqq-atlas .recent-step strong { grid-column:2; grid-row:1 / span 2; }
  #tqqq-atlas .recent-note { line-height:1.6; }
}
body[data-dashboard-tab="research"] > #loading-overlay { display:none !important; }

/* Desktop composition: one alignment grid, compact controls, chart above the fold.
   These overrides deliberately leave the <=640px mobile layout untouched. */
@media (min-width:641px) {
  body > .header,
  body > .dashboard-tabs,
  body > .chart-section,
  body > .bottom-section,
  body > .rules-section,
  body > #main-chart,
  body > .hint {
    width:100%;
    max-width:1648px;
    margin-left:auto;
    margin-right:auto;
  }
  body > .header { padding:16px 24px 14px; }
  body .header-top { display:grid; grid-template-columns:minmax(0,1fr); gap:10px; }
  body .header-title { font-size:22px; }
  body .header-sub { margin-top:5px; line-height:1.5; }
  body .date-range-group {
    width:100%; margin-left:0; justify-content:flex-start; align-items:flex-end;
    padding-top:10px; border-top:1px solid var(--border); gap:8px 12px;
  }
  body .date-range-group .backtest-range-note { flex-basis:100%; line-height:1.4; }
  body .date-range-group input[type="date"] { min-height:34px; }
  body .date-range-group .backtest-apply { min-height:34px; padding:6px 12px; font-size:13px; }
  body .date-range-group #rerun-btn { margin-left:auto; min-height:34px; padding:6px 14px; }
  body .date-shortcuts button { min-height:34px; padding:5px 10px; }
  body .metrics-row {
    display:grid; grid-template-columns:repeat(5,minmax(0,1fr));
    gap:16px; margin-top:14px;
  }
  body .metrics-row > .metric { min-width:0; gap:5px; }
  body .metrics-row .metric-value { font-variant-numeric:tabular-nums; white-space:nowrap; }
  body .live-portfolio { margin-top:12px; padding:10px 14px; }
  body .live-portfolio-top { margin-bottom:8px; }
  body .dashboard-tabs { padding:6px 24px; gap:8px; }
  body .dashboard-tabs button { min-height:34px; padding:6px 16px; font-size:13px; }
  body .chart-section { padding:10px 24px 0; }
  body .chart-section > .section-title { margin-bottom:8px; }
  body .chart-section .signal-toggles { padding:0; margin:0 0 6px; }
  body .chart-controls {
    display:grid; grid-template-columns:auto minmax(0,1fr); align-items:end;
    gap:10px 20px; margin:0 0 8px;
  }
  body .chart-controls > .chart-control-row { gap:6px; }
  body .chart-controls > .chart-control-row:nth-child(2) { justify-content:flex-end; }
  body .chart-controls > .chart-control-row:nth-child(3) { grid-column:1 / -1; align-items:end; }
  body .chart-controls button { min-height:34px; padding:6px 10px; font-size:13px; }
  body .chart-controls label { gap:4px; }
  body .chart-controls input[type="date"] { min-height:34px; font-size:13px; }
  body .chart-controls .chart-view-status { font-size:11px; line-height:1.45; }
  body .chart-controls #chart-series-mode { text-align:right; }
  body #research-section { max-width:1648px; }
}
@media (min-width:1280px) {
  body .date-range-group .backtest-range-note {
    flex:1 1 240px; width:auto; max-width:440px; margin-left:8px;
    order:1; align-self:center; font-size:11px;
  }
  body .date-range-group #rerun-btn { order:2; }
  body .metrics-row { grid-template-columns:repeat(9,minmax(0,1fr)); gap:18px; }
  body .chart-section {
    display:grid; grid-template-columns:minmax(0,1fr) auto;
    align-items:center; column-gap:20px;
  }
  body .chart-section > .section-title { margin-bottom:6px; }
  body .chart-section .signal-toggles { justify-content:flex-end; }
  body .chart-controls { grid-column:1 / -1; grid-template-columns:auto auto minmax(0,1fr); gap:8px 20px; }
  body .chart-controls > .chart-control-row { flex-wrap:nowrap; }
  body .chart-controls > .chart-control-row:nth-child(2) { justify-content:center; }
  body .chart-controls > .chart-control-row:nth-child(3) { grid-column:auto; justify-content:flex-end; }
  body .chart-controls > .chart-control-row:nth-child(3) label { display:flex; align-items:center; gap:6px; white-space:nowrap; font-size:11px; }
  body .chart-controls #chart-view-status { grid-column:1 / 3; }
  body .chart-controls #chart-series-mode { grid-column:3; }
}
@media (min-width:641px) and (max-width:959px) {
  body .date-range-group #rerun-btn { margin-left:0; }
  body .metrics-row { grid-template-columns:repeat(3,minmax(0,1fr)); }
  body .chart-controls { grid-template-columns:minmax(0,1fr); }
  body .chart-controls > .chart-control-row:nth-child(2) { justify-content:flex-start; }
  body .chart-controls #chart-series-mode { text-align:left; }
}
@media (min-width:641px) and (pointer:coarse) {
  body .chart-controls button,
  body .chart-controls input[type="date"],
  body .date-range-group .backtest-apply,
  body .date-range-group input[type="date"],
  body .date-range-group #rerun-btn,
  body .date-shortcuts button,
  body .dashboard-tabs button { min-height:44px; }
}
