/* P0–P10 Final Visual Acceptance · Desktop + Mobile Polish
   No model, data, workflow or trading-logic changes.
   Desktop >= 900px · Mobile < 900px. */

/* ---------- Desktop ---------- */
@media (min-width:900px){
  /* Production / Shadow: keep the decision pane dominant while making the
     six-column scanner fit without a horizontal scrollbar. */
  #productionApp .p-layout,
  #shadowApp .p-layout{
    grid-template-columns:minmax(0,44fr) minmax(0,56fr)!important;
    gap:14px!important;
  }
  #productionApp .p-left-stack,
  #shadowApp .p-left-stack,
  #productionApp .p-table,
  #shadowApp .p-table,
  #productionApp .p-wrap,
  #shadowApp .p-wrap{min-width:0!important}
  #productionApp .p-wrap,
  #shadowApp .p-wrap{
    overflow-y:auto!important;
    overflow-x:hidden!important;
    scrollbar-gutter:stable;
  }
  #productionApp .p-table table,
  #shadowApp .p-table table{
    width:100%!important;
    min-width:0!important;
    max-width:100%!important;
    table-layout:fixed!important;
    font-size:12.5px!important;
  }
  #productionApp .p-table th,
  #shadowApp .p-table th{
    padding:9px 8px!important;
    font-size:10.5px!important;
  }
  #productionApp .p-table td,
  #shadowApp .p-table td{
    padding:9px 8px!important;
    white-space:normal!important;
    overflow-wrap:anywhere;
  }
  #productionApp .p-table td small,
  #shadowApp .p-table td small{
    font-size:11px!important;
    line-height:1.3!important;
  }
  #productionApp .p-table th:nth-child(1),
  #productionApp .p-table td:nth-child(1),
  #shadowApp .p-table th:nth-child(1),
  #shadowApp .p-table td:nth-child(1){width:18%!important}
  #productionApp .p-table th:nth-child(2),
  #productionApp .p-table td:nth-child(2),
  #shadowApp .p-table th:nth-child(2),
  #shadowApp .p-table td:nth-child(2){width:13%!important}
  #productionApp .p-table th:nth-child(3),
  #productionApp .p-table td:nth-child(3),
  #shadowApp .p-table th:nth-child(3),
  #shadowApp .p-table td:nth-child(3){width:13%!important}
  #productionApp .p-table th:nth-child(4),
  #productionApp .p-table td:nth-child(4),
  #shadowApp .p-table th:nth-child(4),
  #shadowApp .p-table td:nth-child(4){width:31%!important}
  #productionApp .p-table th:nth-child(5),
  #productionApp .p-table td:nth-child(5),
  #shadowApp .p-table th:nth-child(5),
  #shadowApp .p-table td:nth-child(5){width:11%!important}
  #productionApp .p-table th:nth-child(6),
  #productionApp .p-table td:nth-child(6),
  #shadowApp .p-table th:nth-child(6),
  #shadowApp .p-table td:nth-child(6){width:14%!important}
  #productionApp .p-table td:nth-child(2),
  #productionApp .p-table td:nth-child(3),
  #productionApp .p-table td:nth-child(5),
  #productionApp .p-table td:nth-child(6),
  #shadowApp .p-table td:nth-child(2),
  #shadowApp .p-table td:nth-child(3),
  #shadowApp .p-table td:nth-child(5),
  #shadowApp .p-table td:nth-child(6){vertical-align:middle!important}

  /* Desktop workspace typography floor: readable on 1440–2048 without
     making dense decision surfaces feel oversized. */
  #productionApp .p-workspace-section-head b,
  #shadowApp .p-workspace-section-head b{font-size:14px!important}
  #productionApp .p-workspace-section-head small,
  #shadowApp .p-workspace-section-head small{font-size:11px!important}
  #productionApp .p-workspace-glance span,
  #shadowApp .p-workspace-glance span{font-size:10.5px!important}
  #productionApp .p-workspace-glance strong,
  #shadowApp .p-workspace-glance strong{font-size:16px!important}
  #productionApp .p-chart-head p,
  #shadowApp .p-chart-head p,
  #productionApp .p2-chart-legend,
  #shadowApp .p2-chart-legend{font-size:11px!important}

  /* Comparison: 2/3 table + 1/3 inspector, wrap explanatory copy and avoid
     unnecessary horizontal scrolling. */
  .comparison-page .c-grid{
    grid-template-columns:minmax(0,2fr) minmax(410px,1fr)!important;
    gap:14px!important;
  }
  .comparison-page .c-table-wrap{overflow-y:auto!important;overflow-x:hidden!important}
  .comparison-page .c-table{
    width:100%!important;
    min-width:0!important;
    table-layout:fixed!important;
    font-size:11.5px!important;
  }
  .comparison-page .c-table th{padding:8px 7px!important;font-size:9.5px!important}
  .comparison-page .c-table td{
    padding:8px 7px!important;
    white-space:normal!important;
    overflow-wrap:anywhere;
  }
  .comparison-page .c-table td:first-child b{font-size:12.5px!important}
  .comparison-page .c-table td:first-child small,
  .comparison-page .c-table td:nth-child(4) small{font-size:10px!important;line-height:1.35!important}
  .comparison-page .c-table th:nth-child(1),.comparison-page .c-table td:nth-child(1){width:12%}
  .comparison-page .c-table th:nth-child(2),.comparison-page .c-table td:nth-child(2){width:15%}
  .comparison-page .c-table th:nth-child(3),.comparison-page .c-table td:nth-child(3){width:9%}
  .comparison-page .c-table th:nth-child(4),.comparison-page .c-table td:nth-child(4){width:27%}
  .comparison-page .c-table th:nth-child(5),.comparison-page .c-table td:nth-child(5){width:9%}
  .comparison-page .c-table th:nth-child(6),.comparison-page .c-table td:nth-child(6){width:9%}
  .comparison-page .c-table th:nth-child(7),.comparison-page .c-table td:nth-child(7){width:7%}
  .comparison-page .c-table th:nth-child(8),.comparison-page .c-table td:nth-child(8){width:8%}
  .comparison-page .c-table th:nth-child(9),.comparison-page .c-table td:nth-child(9){width:4%}
  .comparison-page .c-open-explain{white-space:nowrap!important}
  .comparison-page .c-inspector-head p,
  .comparison-page .c-row span,
  .comparison-page .c-row b{font-size:10px!important}
  .comparison-page .c-model-panel header b{font-size:11px!important}

  /* Forward Research: give the case inspector a little more room. */
  .forward-research-page .f-grid{
    grid-template-columns:minmax(0,2.1fr) minmax(455px,1fr)!important;
    gap:14px!important;
  }
  .forward-research-page .f-table{font-size:11.5px!important}
  .forward-research-page .f-table th{font-size:9.5px!important}
  .forward-research-page .f-table td:first-child b{font-size:12.5px!important}
  .forward-research-page .f-table td:first-child small{font-size:10px!important}

  /* Watchlist: reduce form height so the actual watch table appears sooner. */
  .wp-page .wp-add-panel{padding:10px 12px!important}
  .wp-page .wp-form{gap:7px!important}
  .wp-page .wp-form input,
  .wp-page .wp-form select{padding:7px 8px!important;margin-top:3px!important}
  .wp-page .wp-form textarea{min-height:44px!important;padding:7px 8px!important;margin-top:3px!important}
  .wp-page .wp-form-actions .wp-btn{padding:7px 10px!important}
  .wp-page .wp-table{font-size:12px!important}
  .wp-page .wp-table th{font-size:10px!important}
  .wp-page .wp-ticker small{font-size:10.5px!important}

  /* Dashboard: slightly denser action cards while preserving hierarchy. */
  #dashboardApp .di-grid{gap:10px!important}
  #dashboardApp .di-card{padding:12px 14px!important}
  #dashboardApp .di-action{margin-top:8px!important}
  #dashboardApp .di-card-foot{margin-top:9px!important;padding-top:8px!important}
}

/* Extra-wide desktop should not stretch reading surfaces indefinitely. */
@media (min-width:1680px){
  .comparison-page .c-grid{grid-template-columns:minmax(0,2.15fr) minmax(440px,.9fr)!important}
  .forward-research-page .f-grid{grid-template-columns:minmax(0,2.2fr) minmax(470px,.9fr)!important}
}

/* ---------- Mobile ---------- */
@media (max-width:899px){
  /* Watchlist / Portfolio toolbar: filters first, full-width search second. */
  .wp-page .wp-mobile .wp-toolbar{
    display:grid!important;
    grid-template-columns:1fr!important;
    gap:10px!important;
    align-items:stretch!important;
  }
  .wp-page .wp-mobile .wp-toolbar-left,
  .wp-page .wp-mobile .wp-toolbar-right,
  .wp-page .wp-mobile .wp-search{width:100%!important;min-width:0!important}
  .wp-page .wp-mobile .wp-toolbar-left{display:grid!important;grid-template-columns:repeat(3,minmax(0,1fr))!important}
  .wp-page .wp-mobile .wp-filter{width:100%!important;text-align:center!important}
  .wp-page .wp-mobile .wp-search input{width:100%!important;min-width:0!important}

  /* Stock CTA/header wrapping: keep the action itself intact. */
  .so-page .ri-overview>header{align-items:flex-start!important}
  .so-page .ri-overview .ri-link{
    white-space:nowrap!important;
    flex:0 0 auto!important;
    font-size:13px!important;
  }
  .so-page .so-panel>header h2{white-space:nowrap!important}
  .so-page .so-panel>header small{line-height:1.4!important}
  .so-page .so-page-actions button,
  .so-page .so-page-actions a{white-space:nowrap!important}

  /* Forward Research hero: keep the explanation, but reach the case list sooner. */
  .forward-research-page .f-lens,
  .forward-research-page .f-pipeline-card{padding:12px!important}
  .forward-research-page .f-lens h2{font-size:20px!important;line-height:1.25!important}
  .forward-research-page .f-lens p{font-size:14px!important;line-height:1.45!important;margin-top:7px!important}
  .forward-research-page .f-hero{margin-bottom:10px!important}

  /* Comparison filters: predictable two-column grid + full-width search. */
  .comparison-page .c-tools{display:grid!important;grid-template-columns:1fr!important;gap:10px!important}
  .comparison-page .c-filter-group{
    display:grid!important;
    grid-template-columns:repeat(2,minmax(0,1fr))!important;
    gap:7px!important;
  }
  .comparison-page .c-filter{width:100%!important;min-width:0!important;text-align:center!important}
  .comparison-page .c-filter-group .c-filter:last-child:nth-child(odd){grid-column:1/-1}
  .comparison-page .c-search{width:100%!important;min-width:0!important}
  .comparison-page .p-head h1{font-size:30px!important;line-height:1.12!important}

  /* Daily Changes filters: remove the orphaned All chip. */
  .daily-changes-page .dc-filter-row{display:grid!important;grid-template-columns:1fr!important;gap:9px!important}
  .daily-changes-page .dc-pills{
    display:grid!important;
    grid-template-columns:repeat(2,minmax(0,1fr))!important;
    gap:7px!important;
    margin:0!important;
  }
  .daily-changes-page .dc-pills button{width:100%!important;min-width:0!important;text-align:center!important}
  .daily-changes-page .dc-pills button:last-child:nth-child(odd){grid-column:1/-1}
  .daily-changes-page .dc-filter-row select,
  .daily-changes-page .dc-search{width:100%!important;margin:0!important}

  /* Production / Shadow setup lists: reduce unused vertical space only. */
  #productionApp .p-mobile-section-head.setup + .p-mobile-list .p-mobile-card summary,
  #shadowApp .p-mobile-section-head.setup + .p-mobile-list .p-mobile-card summary{
    padding:12px 14px!important;
  }
  #productionApp .p-mobile-section-head.setup + .p-mobile-list,
  #shadowApp .p-mobile-section-head.setup + .p-mobile-list{gap:8px!important}
}

/* Narrow iPhone: protect action labels from awkward three-line wrapping. */
@media (max-width:430px){
  .so-page .ri-overview>header{gap:8px!important}
  .so-page .ri-overview .ri-link{font-size:12px!important}
  .comparison-page .p-head h1{font-size:29px!important}
}
