:root { overscroll-behavior-x: none; }
body { overscroll-behavior-x: none; }
.shell, .panel, .market-tools, .market-tools label, .form-grid > *, .lotRow > * { min-width: 0; }
select, input, .market-tools label, .divTools > * { max-width: 100%; }
.dialog, .smallprint, .divCard, .divNote, #status, #scope, .market-status { overflow-wrap: anywhere; }
body:has(dialog[open]) { overflow: hidden; }
.intro .tools { justify-content: flex-end; }
.panel-head { padding-bottom: .5rem; }
.panel-head .market-tools label { display: flex; align-items: center; gap: .3rem; }
.market-status { font-size: .84rem; }
.scroll { overflow: visible; }
.holdings-table, .trades-table { table-layout: fixed; white-space: normal; overflow-wrap: anywhere; }
.holdings-table th { background: #edf4f1; color: #46635b; }
.holdings-table :is(td, th) { padding-inline: 1.2rem; }
.holdings-table td { padding-block: .7rem; font-variant-numeric: tabular-nums; }
.holdings-table th:first-child { width: 40%; }
.holdings-table th:last-child { width: 8rem; }
.holdings-table tr:hover td { background: #f7faf8; }
.holdings-table .stock-link { text-align: left; text-decoration: none; color: #124e48; font-size: 1.02rem; }
.holdings-table td small { line-height: 1.2; font-size: .79rem; letter-spacing: .035em; color: #586e69; }
.holdings-table .average { font-weight: 650; }
.profit-trigger { font-size: .88rem; padding: .45rem .68rem; border: 1px solid #bbd3ca; color: #055d53; background: #f4f9f6; white-space: nowrap; }
.trades-table :is(th, td) { padding-inline: .5rem; }
#profitDlg { padding: 0; width: min(94vw, 35rem); overscroll-behavior: contain; overflow-wrap: anywhere; }
.profit-head { position: sticky; top: 0; z-index: 1; display: flex; align-items: center; justify-content: space-between; gap: .75rem; padding: 1rem 1.3rem; background: #104b48; color: white; border: 0; }
.profit-head h2 { font-size: 1.22rem; }
.profit-head p { color: #cee5dd; font-size: .87rem; }
.profit-head button { flex: none; }
#profitBody { padding: 1.15rem 1.25rem 1.4rem; }
.profit-pair { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); margin: 0 0 .75rem; border-radius: .65rem; background: #edf4f0; }
#profitBody > button:first-child { margin-bottom: .8rem; }
.profit-pair > div { padding: .8rem; }
.profit-pair > div + div { border-left: 1px solid #d3e2da; }
.profit-pair dt { color: #44645a; font-size: .85rem; }
.profit-pair dd { margin: .25rem 0 0; font-size: clamp(1.02rem,4vw,1.45rem); font-weight: 750; font-variant-numeric: tabular-nums; }
.profit-section { margin-top: 1.15rem; }
.profit-section h3 { font-size: 1rem; color: #285c50; margin: 0 0 .3rem; }
.profit-facts { margin: 0; }
.profit-facts > div, .stock-breakdown { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; border-bottom: 1px solid var(--line); padding: .45rem 0; }
.profit-facts dt { color: var(--sub); }
.profit-facts dd { text-align: right; font-variant-numeric: tabular-nums; margin: 0; }
.stock-breakdown { width: 100%; text-align: left; color: var(--teal); background: transparent; border-width: 0 0 1px; border-radius: 0; }
.stock-breakdown span { color: var(--sub); flex-shrink: 0; }
.profit-actions { display: flex; gap: .6rem; flex-wrap: wrap; margin-top: 1.1rem; }
.profit-actions button, .profit-head button { padding: .5rem .8rem; }
.form-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
.form-grid input, .form-grid select { width: 100%; }
dialog { overscroll-behavior: contain; }
.saleTable, .detail-main table { table-layout: fixed; white-space: normal; overflow-wrap: anywhere; }
#saleAccounts button, #stockHints button, .legend { max-width: 100%; overflow-wrap: anywhere; }
@media (max-width: 960px) {
  .trades-table, .trades-table tbody { display: block; }
  .trades-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .trades-table tr { display: grid; grid-template-columns: minmax(0,1fr) minmax(0,1fr); border-top: 1px solid var(--line); gap: .25rem 1rem; padding: .8rem 1rem; }
  .trades-table td { display: block; border: 0; text-align: left; padding: .12rem 0; }
  .trades-table td::before { content: attr(data-label); display: block; color: var(--sub); font-size: .78rem; }
  .trades-table td:last-child { grid-column: 1/-1; display: flex; gap: .4rem; flex-wrap: wrap; }
  .trades-table td:last-child::before { display: none; }
}
@media (max-width: 600px) {
  .shell { padding-inline: .7rem; }
  .intro { align-items: center; flex-wrap: wrap; gap: .55rem; }
  .intro .tools { gap: .38rem; }
  .intro .tools button { padding: .5rem .65rem; font-size: .91rem; }
  .panel { margin-top: .95rem; }
  .tabs { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 0; padding: 0 .2rem; }
  .tab { padding: .75rem .1rem; font-size: .91rem; }
  .panel-head { align-items: flex-start; }
  .market-tools { gap: .4rem; max-width: 100%; }
  .market-status { margin-inline: .8rem; }
  .holdings-table :is(td, th) { padding-inline: .32rem; }
  .holdings-table :is(th, td):first-child { padding-left: .64rem; }
  .holdings-table :is(th, td):last-child { padding-right: .55rem; }
  .holdings-table th:first-child { width: auto; }
  .holdings-table th:nth-child(2) { width: 24%; }
  .holdings-table th:nth-child(3) { width: 18%; }
  .holdings-table th:last-child { width: 5.1rem; }
  .holdings-table td { padding-block: .55rem; font-size: .94rem; }
  .holdings-table .stock-link { font-size: .99rem; }
  .profit-trigger { min-height: 44px; font-size: .85rem; padding: .35rem .45rem; }
  #profitDlg { width: 100%; max-width: 100%; height: 100%; height: 100dvh; max-height: 100%; max-height: 100dvh; margin: 0; border: 0; border-radius: 0; }
  .profit-head { padding: max(.8rem,env(safe-area-inset-top)) 1rem .8rem; }
  #profitBody { padding: 1rem 1rem max(1.4rem,env(safe-area-inset-bottom)); }
  .profit-head button { min-height: 44px; }
  .lotRow { grid-template-columns: minmax(0,1fr) minmax(0,.95fr) minmax(3.6rem,.65fr); overflow-wrap: anywhere; }
  .lotRow input[type="number"] { width: 100%; }
  .smallprint { margin-bottom: 1rem; }
}
#shotDlg {width:min(100%,40rem);padding:0;overflow-wrap:anywhere;}
.shot-main {padding:1rem;}
.shot-main h3 {font-size:1.05rem;margin:.8rem 0 .25rem;}
.shot-main input:not([type=checkbox]), .shot-main select {width:100%;max-width:100%;font-size:1rem;}
.shot-main input[type=file] {white-space:normal;}
.shot-page,.shot-row {padding:.7rem 0;border-bottom:1px solid var(--line);}
.shot-page summary {cursor:pointer;color:var(--teal);}
.shot-page img {max-width:100%;max-height:20rem;display:block;margin:.4rem auto;}
.shot-page .form-grid,.shot-row .form-grid {margin:.5rem 0;gap:.48rem;}
.shot-row strong,.shot-row label {font-size:.94rem;}
.shot-state {font-size:.88rem;color:var(--sub);}
.shot-row[data-status=new] .shot-state,#shotCount {font-weight:650;color:var(--teal);}
.shot-row[data-status=conflict] .shot-state {color:#8a4414;}
#shotProgress:not(:empty),#shotCount {margin:.65rem 0;}
#shotPreview {margin-top:.75rem;}
.shot-actions {display:flex;gap:.5rem;align-items:center;flex-wrap:wrap;}
@media(max-width:600px){#shotDlg{width:100%;max-width:100%;height:100dvh;max-height:100dvh;margin:0;border:0;border-radius:0;}.shot-main{padding-bottom:max(1.5rem,env(safe-area-inset-bottom));}}
