/* DPX v0.6.6 approved targeted patches. Loaded after all v0.6.5 styles. */

/* Separate Daily Recommendations lower tab/panel. */
.daily-recommendations-card {
  width: 100% !important;
  min-width: 0 !important;
  margin: 0 !important;
  padding: 10px !important;
  overflow: hidden !important;
}
.daily-recommendations-card .auto-recommendation-panel {
  margin: 0 !important;
  padding: 8px !important;
  border: 1px solid rgba(121,247,165,.14) !important;
  border-radius: 12px !important;
  background: rgba(8,15,27,.58) !important;
}
.daily-recommendations-card .auto-output-box {
  min-height: 150px !important;
  max-height: 430px !important;
  overflow: auto !important;
  white-space: pre-wrap !important;
}
body.desktop-tab-layout .desktop-tab-panels > .ledger-card,
body.desktop-tab-layout .desktop-tab-panels > .auto-trading-card,
body.desktop-tab-layout .desktop-tab-panels > .daily-recommendations-card { display: none !important; }
body.desktop-tab-layout.desktop-tab-history .desktop-tab-panels > .ledger-card,
body.desktop-tab-layout.desktop-tab-setup .desktop-tab-panels > .auto-trading-card,
body.desktop-tab-layout.desktop-tab-recommendations .desktop-tab-panels > .daily-recommendations-card { display: block !important; }
body.phone-tab-layout #phoneTabPanels > [aria-hidden="true"] { display: none !important; }
body.phone-tab-layout #phoneTabPanels > [aria-hidden="false"] { display: block !important; }
body.phone-tab-layout.phone-tab-recommendations #dailyRecommendationsPanel { display: block !important; }

/* Phone lower tabs: six compact, readable tabs without clipping. */
body.phone-tab-layout .phone-tab-list {
  grid-template-columns: repeat(6,minmax(0,1fr)) !important;
}
body.phone-tab-layout .phone-bottom-tab {
  min-width: 0 !important;
  padding-inline: 1px !important;
  font-size: clamp(7.5px,2.35vw,10px) !important;
  white-space: nowrap !important;
}

/* Compact Auto Trade Setting: checkbox beside its label, 2–3 per row. */
.auto-setting-split {
  display: block !important;
  margin: 0 8px 8px !important;
}
.auto-setting-checks {
  display: grid !important;
  grid-template-columns: repeat(3,minmax(0,1fr)) !important;
  gap: 6px 8px !important;
  margin: 0 0 8px !important;
}
.auto-setting-checks .checkbox-field {
  display: flex !important;
  flex-direction: row !important;
  align-items: center !important;
  justify-content: flex-start !important;
  gap: 6px !important;
  min-width: 0 !important;
  min-height: 28px !important;
  padding: 3px 5px !important;
}
.auto-setting-checks .checkbox-field > span {
  flex: 0 1 auto !important;
  min-width: 0 !important;
  margin: 0 !important;
  text-align: left !important;
  white-space: normal !important;
}
.auto-setting-checks .checkbox-field > input[type="checkbox"] {
  flex: 0 0 auto !important;
  margin: 0 !important;
  order: 2 !important;
}
.auto-setting-inputs,
.auto-rule-details .auto-setting-inputs,
.auto-collapsible-grid.logic-expanded-view .auto-setting-inputs {
  display: grid !important;
  grid-template-columns: repeat(3,minmax(0,1fr)) !important;
  gap: 7px !important;
  align-items: end !important;
}
/* Put the three requested minimums together at the start. */
.auto-setting-inputs .param-target-profit { order: 1 !important; }
.auto-setting-inputs .param-projected-profit { order: 2 !important; }
.auto-setting-inputs .param-net-pnl { order: 3 !important; }
.auto-setting-inputs .param-stop-loss { order: 4 !important; }
.auto-setting-inputs .param-auto-fee { order: 5 !important; }
.auto-setting-inputs .param-decline-pnl { order: 6 !important; }
.auto-setting-inputs .param-risk-reward { order: 7 !important; }
.auto-setting-inputs .param-model-score { order: 8 !important; }
.auto-setting-inputs .param-volatility { order: 9 !important; }
.auto-setting-inputs .param-skipped-window { order: 10 !important; }

/* Laptop header alignment and larger requested labels. */
@media (min-width: 901px) {
  body.desktop-tab-layout .hero {
    grid-template-columns: minmax(150px,1fr) auto auto !important;
    column-gap: 7px !important;
  }
  body.desktop-tab-layout .hero .connection-pill,
  body.desktop-tab-layout .hero #connectionStatus {
    justify-self: end !important;
    margin-right: 0 !important;
  }
  body.desktop-tab-layout .hero-market-slot {
    justify-self: end !important;
    min-width: 205px !important;
  }
  body.desktop-tab-layout #accountMenuBtn,
  body.desktop-tab-layout .session-account-slot .account-menu-btn,
  body.desktop-tab-layout .compact-account-strip .account-menu-btn {
    font-size: clamp(15px,1.15vw,21px) !important;
  }
  body.desktop-tab-layout .effective-trade-settings .effective-trade-item {
    font-size: clamp(12px,1.02vw,16px) !important;
    line-height: 1.2 !important;
  }
  body.desktop-tab-layout .effective-trade-settings {
    display: flex !important;
    align-items: center !important;
    gap: clamp(12px,1.7vw,28px) !important;
    min-width: 0 !important;
  }
  body.desktop-tab-layout #ledgerTable th,
  body.desktop-tab-layout #ledgerTable td {
    font-size: 11px !important;
    line-height: 1.2 !important;
    padding: 5px 6px !important;
  }
  body.desktop-tab-layout #ledgerTable .ledger-stack-line b { font-size: 9px !important; }
  body.desktop-tab-layout #ledgerTable .ledger-stack-line em { font-size: 10.5px !important; }
  body.desktop-tab-layout #ledgerTable td { height: 44px !important; }
  body.desktop-tab-layout.user-normal #ledgerTable,
  body.desktop-tab-layout.non-admin-ledger #ledgerTable {
    min-width: 100% !important;
    width: 100% !important;
    table-layout: fixed !important;
  }
  body.desktop-tab-layout.user-normal #ledgerTable .ledger-col-tradeCount { width: 9% !important; }
  body.desktop-tab-layout.user-normal #ledgerTable .ledger-col-entryExit { width: 14% !important; }
  body.desktop-tab-layout.user-normal #ledgerTable .ledger-col-stopLoss { width: 13% !important; }
  body.desktop-tab-layout.user-normal #ledgerTable .ledger-col-targetExit { width: 13% !important; }
  body.desktop-tab-layout.user-normal #ledgerTable .ledger-col-createdSettled { width: 17% !important; }
  body.desktop-tab-layout.user-normal #ledgerTable .ledger-col-duration { width: 8% !important; }
  body.desktop-tab-layout.user-normal #ledgerTable .ledger-col-pnl { width: 9% !important; }
  body.desktop-tab-layout.user-normal #ledgerTable .ledger-col-closeReason { width: 17% !important; }
}

/* Separate Auto status from the combined manual+auto Today count. */
.trade-title-status {
  display: flex !important;
  align-items: center !important;
  gap: 6px !important;
  min-width: 0 !important;
}
.today-trade-count {
  white-space: nowrap !important;
  flex: 0 0 auto !important;
}

/* Phone admin: keep Entry/Adjust values editable but slightly reduce oversized text. */
@media (max-width: 600px) and (orientation: portrait) {
  body.phone-tab-layout #phoneEntryPanel .horizon-param-grid .text-input,
  body.phone-tab-layout #phoneAdjustPanel .horizon-param-grid .text-input {
    font-size: clamp(12px,3.65vw,15px) !important;
    padding-inline: 3px !important;
    min-width: 0 !important;
  }
  body.phone-tab-layout #phoneSettingPanel .auto-setting-checks {
    grid-template-columns: repeat(2,minmax(0,1fr)) !important;
    gap: 5px !important;
  }
  body.phone-tab-layout #phoneSettingPanel .auto-setting-inputs {
    grid-template-columns: repeat(2,minmax(0,1fr)) !important;
    gap: 6px !important;
  }
  body.phone-tab-layout #phoneSettingPanel .auto-setting-checks .checkbox-field {
    min-height: 27px !important;
    padding: 2px 3px !important;
  }
  body.phone-tab-layout #phoneSettingPanel .auto-setting-checks .checkbox-field > span,
  body.phone-tab-layout #phoneSettingPanel .auto-setting-inputs label > span {
    font-size: clamp(9px,2.65vw,11px) !important;
    line-height: 1.12 !important;
  }
  body.phone-tab-layout #phoneSettingPanel .auto-setting-inputs .text-input {
    font-size: clamp(12px,3.5vw,15px) !important;
    min-height: 31px !important;
    height: 31px !important;
  }

  /* Admin phone: values remain, repeated IN/OUT/ORIG/ADJ/MADE/DONE labels do not. */
  body.phone-tab-layout.user-admin #ledgerTable .phone-inout-cell .phone-value-stack b,
  body.phone-tab-layout.user-admin #ledgerTable .phone-target-sl-cell .phone-value-stack b,
  body.phone-tab-layout.user-admin #ledgerTable .phone-made-done-cell .phone-value-stack b {
    display: none !important;
  }
  body.phone-tab-layout.user-admin #ledgerTable .phone-inout-cell .phone-value-stack > span,
  body.phone-tab-layout.user-admin #ledgerTable .phone-target-sl-cell .phone-value-stack > span,
  body.phone-tab-layout.user-admin #ledgerTable .phone-made-done-cell .phone-value-stack > span {
    display: block !important;
    min-width: 0 !important;
  }

  /* Historical rows: largest safe font, left-aligned reason, two lines for long flips. */
  body.phone-tab-layout #ledgerTable th,
  body.phone-tab-layout #ledgerTable td {
    font-size: clamp(8.5px,2.45vw,10.5px) !important;
    line-height: 1.18 !important;
  }
  body.phone-tab-layout #ledgerTable .phone-ledger-stack b { font-size: clamp(8px,2.25vw,10px) !important; }
  body.phone-tab-layout #ledgerTable .phone-ledger-stack em { font-size: clamp(8.5px,2.45vw,10.5px) !important; }
  body.phone-tab-layout.user-normal #ledgerTable .ledger-col-closeReason,
  body.phone-tab-layout.user-normal #ledgerTable .reason-cell,
  body.phone-tab-layout.non-admin-ledger #ledgerTable .ledger-col-closeReason,
  body.phone-tab-layout.non-admin-ledger #ledgerTable .reason-cell {
    text-align: left !important;
    vertical-align: middle !important;
    white-space: normal !important;
    overflow-wrap: anywhere !important;
    line-height: 1.2 !important;
    font-size: clamp(10px,2.85vw,12px) !important;
  }
  body.phone-tab-layout.user-normal #ledgerTable .reason-cell > *,
  body.phone-tab-layout.non-admin-ledger #ledgerTable .reason-cell > * {
    text-align: left !important;
    margin-left: 0 !important;
  }
  body.phone-tab-layout.user-normal #ledgerTable .reason-cell,
  body.phone-tab-layout.non-admin-ledger #ledgerTable .reason-cell {
    min-width: 0 !important;
    max-height: 2.45em !important;
    overflow: hidden !important;
    display: table-cell !important;
  }

  .trade-title-status { gap: 4px !important; }
  .today-trade-count,
  .trading-auto-status { font-size: clamp(8px,2.35vw,10px) !important; padding-inline: 5px !important; }
  .daily-recommendations-card .auto-output-box { min-height: 260px !important; max-height: 60vh !important; }
}

/* Final phone Historical Orders text treatment from the approved client markup. */
@media (max-width: 600px) and (orientation: portrait) {
  body.phone-tab-layout.user-admin #ledgerTable .entry-exit-stack .ledger-stack-line b,
  body.phone-tab-layout.user-admin #ledgerTable .orig-adj-stack .ledger-stack-line b,
  body.phone-tab-layout.user-admin #ledgerTable .created-settled-stack .ledger-stack-line b {
    display: none !important;
  }
  body.phone-tab-layout.user-normal #ledgerTable .dpx-ledger-reason-text,
  body.phone-tab-layout.non-admin-ledger #ledgerTable .dpx-ledger-reason-text {
    display: -webkit-box !important;
    -webkit-box-orient: vertical !important;
    -webkit-line-clamp: 2 !important;
    line-clamp: 2 !important;
    white-space: normal !important;
    overflow: hidden !important;
    text-overflow: clip !important;
    overflow-wrap: anywhere !important;
    text-align: left !important;
    line-height: 1.2 !important;
    max-height: 2.4em !important;
    margin: 0 !important;
  }
}
.dpx-phone-reason-break { display: none !important; }
@media (max-width: 600px) and (orientation: portrait) {
  body.phone-tab-layout.user-normal .dpx-phone-reason-break,
  body.phone-tab-layout.non-admin-ledger .dpx-phone-reason-break {
    display: block !important;
  }
}
@media (max-width: 600px) and (orientation: portrait) {
  html body.phone-tab-layout.user-normal.non-admin-ledger.dpx-phone-ledger-user
  #phoneHistoryPanel #ledgerTableWrap #ledgerTable .reason-cell,
  html body.phone-tab-layout.user-normal.non-admin-ledger.dpx-phone-ledger-user
  #phoneHistoryPanel #ledgerTableWrap #ledgerTable .reason-cell .dpx-ledger-reason-text {
    font-size: clamp(10px, 2.95vw, 11.5px) !important;
    line-height: 1.2 !important;
    text-align: left !important;
    white-space: normal !important;
  }
}
@media (max-width: 600px) and (orientation: portrait) {
  html body.phone-tab-layout.user-normal.non-admin-ledger.dpx-phone-ledger-user
  #phoneHistoryPanel #ledgerTableWrap #ledgerTable .ledger-col-closeReason,
  html body.phone-tab-layout.user-normal.non-admin-ledger.dpx-phone-ledger-user
  #phoneHistoryPanel #ledgerTableWrap #ledgerTable .reason-cell {
    width: 240px !important;
    min-width: 240px !important;
    max-width: 240px !important;
  }
}


/* DPX v0.6.6 corrective patch list -16 */
@media (min-width: 901px) {
  /* Restore/increase desktop ledger text and recover COUNT space for REASON. */
  body.desktop-tab-layout #ledgerTable th,
  body.desktop-tab-layout #ledgerTable td {
    font-size: clamp(13px, 0.92vw, 16px) !important;
    line-height: 1.18 !important;
    padding: 6px 7px !important;
  }
  body.desktop-tab-layout #ledgerTable .ledger-stack-line b { font-size: clamp(11px, .78vw, 13px) !important; }
  body.desktop-tab-layout #ledgerTable .ledger-stack-line em { font-size: clamp(12px, .86vw, 15px) !important; }
  body.desktop-tab-layout.user-normal #ledgerTable .ledger-col-tradeCount,
  body.desktop-tab-layout.non-admin-ledger #ledgerTable .ledger-col-tradeCount { width: 7% !important; }
  body.desktop-tab-layout.user-normal #ledgerTable .ledger-col-closeReason,
  body.desktop-tab-layout.non-admin-ledger #ledgerTable .ledger-col-closeReason { width: 23% !important; }
  body.desktop-tab-layout.user-normal #ledgerTable .dpx-ledger-reason-text,
  body.desktop-tab-layout.non-admin-ledger #ledgerTable .dpx-ledger-reason-text {
    display: -webkit-box !important;
    -webkit-box-orient: vertical !important;
    -webkit-line-clamp: 2 !important;
    line-clamp: 2 !important;
    white-space: normal !important;
    overflow: hidden !important;
    line-height: 1.18 !important;
    max-height: 2.36em !important;
  }
}

@media (max-width: 600px) and (orientation: portrait) {
  /* Entry/Adjust: smaller value text and full-field pointer target. */
  body.phone-tab-layout #phoneEntryPanel .horizon-param-grid .text-input,
  body.phone-tab-layout #phoneAdjustPanel .horizon-param-grid .text-input {
    font-size: clamp(11px, 3.1vw, 13px) !important;
    padding: 4px 8px !important;
    width: 100% !important;
    min-height: 42px !important;
    position: relative !important;
    z-index: 2 !important;
    pointer-events: auto !important;
  }
  body.phone-tab-layout #phoneEntryPanel .horizon-param-grid label,
  body.phone-tab-layout #phoneAdjustPanel .horizon-param-grid label { pointer-events: auto !important; }

  /* Restore ledger fonts to at least v0.6.5 and maximize admin portrait safely. */
  body.phone-tab-layout #ledgerTable th { font-size: clamp(10.5px, 3vw, 13px) !important; }
  body.phone-tab-layout #ledgerTable td { font-size: clamp(11px, 3.15vw, 14px) !important; line-height: 1.18 !important; }
  body.phone-tab-layout #ledgerTable .phone-ledger-stack b,
  body.phone-tab-layout #ledgerTable .ledger-stack-line b { font-size: clamp(10px, 2.9vw, 12.5px) !important; }
  body.phone-tab-layout #ledgerTable .phone-ledger-stack em,
  body.phone-tab-layout #ledgerTable .ledger-stack-line em { font-size: clamp(10.8px, 3.05vw, 13.5px) !important; }
  body.phone-tab-layout.user-admin #ledgerTable td { font-size: clamp(11.5px, 3.25vw, 14px) !important; }

  /* Compact CREA/SETT for both roles. */
  body.phone-tab-layout #ledgerTable .ledger-col-createdSettled {
    width: 118px !important;
    min-width: 118px !important;
    max-width: 118px !important;
    padding-left: 3px !important;
    padding-right: 3px !important;
  }

  /* Normal-user P&L and reason alignment with no artificial gap. */
  body.phone-tab-layout.user-normal #ledgerTable .ledger-col-pnl,
  body.phone-tab-layout.non-admin-ledger #ledgerTable .ledger-col-pnl,
  body.phone-tab-layout.user-normal #ledgerTable td.ledger-col-pnl,
  body.phone-tab-layout.non-admin-ledger #ledgerTable td.ledger-col-pnl {
    width: 78px !important;
    min-width: 78px !important;
    max-width: 78px !important;
    text-align: left !important;
    padding-left: 3px !important;
    padding-right: 3px !important;
  }
  body.phone-tab-layout.user-normal #ledgerTable .ledger-col-closeReason,
  body.phone-tab-layout.non-admin-ledger #ledgerTable .ledger-col-closeReason,
  body.phone-tab-layout.user-normal #ledgerTable .reason-cell,
  body.phone-tab-layout.non-admin-ledger #ledgerTable .reason-cell {
    width: 190px !important;
    min-width: 190px !important;
    max-width: 190px !important;
    text-align: left !important;
    padding-left: 3px !important;
    padding-right: 3px !important;
  }
  body.phone-tab-layout.user-normal #ledgerTable .reason-cell .settle-btn,
  body.phone-tab-layout.non-admin-ledger #ledgerTable .reason-cell .settle-btn,
  body.phone-tab-layout.user-normal #ledgerTable .reason-cell button,
  body.phone-tab-layout.non-admin-ledger #ledgerTable .reason-cell button {
    min-width: 0 !important;
    width: auto !important;
    padding: 3px 7px !important;
    font-size: 10px !important;
    line-height: 1.1 !important;
  }
}
