/* MyTradeHub site-wide spacing, divider and overlap consistency layer.
   Loaded last. Keep component semantics intact; normalize only geometry and readability. */

:root{
  --mth-space-1:6px;
  --mth-space-2:10px;
  --mth-space-3:14px;
  --mth-space-4:18px;
  --mth-space-5:24px;
  --mth-space-6:30px;
}

/* Core overflow safety */
.modal,
.drawer,
#modalContent,
#drawerContent,
.tradehub-detail,
.auction-detail-shell,
.inventory-passport,
.mth-listing-row,
.mth-row-main,
.mth-row-copy,
.mth-row-intent,
.mth-row-wants,
.profile-head,
.profile-tabs{
  min-width:0;
  box-sizing:border-box;
}
.modal *,
.drawer *,
.mth-listing-row *{
  box-sizing:border-box;
}
.modal strong,
.modal span,
.modal small,
.drawer strong,
.drawer span,
.drawer small{
  overflow-wrap:anywhere;
}

/* Generic modal rhythm */
.modal>#modalContent{
  min-width:0;
}
.modal #modalContent>p.eyebrow{
  margin:0 0 6px;
}
.modal #modalContent>h2{
  margin:0 0 14px;
  line-height:1.16;
}
.modal-actions{
  display:flex;
  flex-wrap:wrap;
  align-items:center;
  justify-content:flex-end;
  gap:8px;
}
.modal-actions>button{
  min-width:0;
}

/* Trade listing detail */
.modal:has(.tradehub-detail){
  width:min(1040px,calc(100vw - 32px))!important;
  max-width:1040px!important;
  max-height:calc(100dvh - var(--mth-header-height,68px) - 24px)!important;
  padding:26px!important;
  overflow-x:hidden!important;
}
.tradehub-detail{
  display:flex;
  flex-direction:column;
  gap:18px;
}
.tradehub-detail-head{
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap:16px;
  padding-right:42px;
}
.tradehub-detail-head>div{
  min-width:0;
}
.tradehub-detail-head h2{
  margin:4px 0 6px;
  line-height:1.15;
}
.tradehub-detail-head p{
  margin:0;
  color:var(--muted);
  line-height:1.4;
}
.tradehub-detail-head .status{
  flex:0 0 auto;
}
.tradehub-detail-assets{
  display:grid;
  grid-template-columns:repeat(auto-fit,minmax(220px,1fr));
  gap:10px;
}
.tradehub-detail-asset{
  min-width:0;
  display:grid;
  grid-template-columns:42px minmax(0,1fr);
  align-items:center;
  gap:10px;
  width:100%;
  padding:11px 12px;
  border:1px solid var(--line);
  border-radius:12px;
  background:var(--surface-2);
  color:inherit;
  text-align:left;
}
.tradehub-detail-asset-icon{
  width:42px;
  height:42px;
  display:grid;
  place-items:center;
  color:#9278ff;
}
.tradehub-detail-asset-icon .mth-icon-svg{
  width:34px;
  height:34px;
}
.tradehub-detail-asset-copy{
  min-width:0;
  display:flex;
  flex-direction:column;
  gap:3px;
}
.tradehub-detail-asset-copy strong{
  font-size:.82rem;
  line-height:1.2;
}
.tradehub-detail-asset-copy small{
  display:block;
  color:var(--muted);
  font-size:.8rem;
  line-height:1.28;
}
.tradehub-detail-asset-copy .tradehub-detail-asset-value{
  color:var(--ink);
  font-weight:800;
}
.tradehub-detail-section{
  border-top:1px solid var(--line);
  padding-top:16px;
}
.tradehub-detail-section h3{
  margin:0 0 10px;
  font-size:.94rem;
  line-height:1.2;
}
.tradehub-detail-requirement{
  display:grid;
  grid-template-columns:minmax(120px,auto) minmax(0,1fr);
  align-items:start;
  gap:12px;
  padding:10px 0;
  border-bottom:1px solid color-mix(in srgb,var(--line) 78%,transparent);
}
.tradehub-detail-requirement:last-child{
  border-bottom:0;
}
.tradehub-detail-requirement strong{
  font-size:.8rem;
  line-height:1.3;
}
.tradehub-detail-requirement span{
  color:var(--muted);
  font-size:.8rem;
  line-height:1.4;
}
.tradehub-detail-terms{
  display:flex;
  flex-wrap:wrap;
  gap:7px;
}
.tradehub-detail-terms>span{
  display:inline-flex;
  align-items:center;
  min-height:30px;
  padding:5px 9px;
  border:1px solid var(--line);
  border-radius:999px;
  background:var(--surface-2);
  font-size:.8rem;
  line-height:1.2;
}
.tradehub-detail-value{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:16px;
  padding:13px 14px;
  border:1px solid var(--line);
  border-radius:12px;
  background:var(--surface-2);
}
.tradehub-detail-value span{
  color:var(--muted);
  font-size:.8rem;
}
.tradehub-detail-value strong{
  flex:0 0 auto;
  font-family:Manrope,sans-serif;
  font-size:1rem;
}
.tradehub-detail>.mth-approx-location{
  margin-top:0;
}
.tradehub-detail>.modal-actions{
  margin-top:0;
  padding-top:2px;
}

/* Approximate location panel */
.mth-approx-location{
  margin-top:18px;
}
.mth-approx-location-head{
  gap:16px;
}
.mth-approx-location-head h3{
  line-height:1.25;
}
.mth-approx-map{
  min-height:220px;
}
.mth-approx-map .leaflet-control-container{
  font-size:13px;
}

/* Auction detail spacing */
.modal:has(.auction-detail-shell){
  padding:26px!important;
}
.auction-detail-shell{
  align-items:start;
}
.auction-detail-main{
  min-width:0;
  display:flex;
  flex-direction:column;
  gap:0;
}
.auction-detail-main>.eyebrow{
  margin:0 0 5px!important;
}
.auction-detail-main>.auction-modal-location{
  margin:2px 0 0;
  line-height:1.35;
}
.auction-detail-main>.auction-rule-note,
.auction-detail-main>.partner-note,
.auction-detail-main>.mth-approx-location{
  width:100%;
}
.auction-detail-facts{
  display:flex;
  flex-wrap:wrap;
  gap:7px;
}
.auction-detail-facts>span{
  margin:0!important;
}
.auction-bid-box{
  min-width:0;
}
.auction-bid-box-grid{
  gap:0;
}
.auction-bid-box-grid>div{
  min-width:0;
}
.auction-bid-actions{
  display:flex;
  flex-direction:column;
  gap:8px;
}
.auction-bid-actions .modal-actions{
  margin-top:0;
}

/* Shared listing rows */
.mth-listing-row{
  overflow:hidden;
}
.mth-row-copy{
  gap:0;
}
.mth-row-meta{
  row-gap:4px;
}
.mth-row-wants{
  min-width:0;
}
.mth-row-want{
  overflow:hidden;
}
.mth-row-actions{
  min-width:118px;
}
.mth-row-actions button{
  white-space:normal;
  line-height:1.18;
}

/* Profile */
.profile-head{
  gap:16px;
}
.profile-identity{
  min-width:0;
}
.profile-stats{
  min-width:0;
}
.profile-tabs{
  gap:14px;
  scrollbar-width:thin;
}
.profile-tabs button{
  display:inline-flex;
  align-items:center;
  gap:5px;
}
#profileContent{
  min-width:0;
}
#profileContent .profile-section-head,
#profileContent .profile-listing-group-head{
  gap:12px;
}

/* Inventory drawer */
.inventory-passport{
  min-width:0;
}
.inventory-passport h2,
.inventory-passport-location{
  overflow-wrap:anywhere;
}
.inventory-core-facts>div,
.inventory-detail-row{
  min-width:0;
}
.inventory-core-facts span,
.inventory-detail-row span{
  flex:1 1 auto;
}
.inventory-core-facts strong,
.inventory-detail-row strong{
  flex:0 1 60%;
  overflow-wrap:anywhere;
}
.inventory-passport-actions{
  flex-wrap:wrap;
}
.inventory-passport-actions button{
  min-width:130px;
}

/* Create listing / picker */
.listing-picker-head,
.listing-picker-section-head,
.listing-picker-footer{
  min-width:0;
}
.listing-picker-card{
  min-width:0;
}
.listing-picker-grid{
  scroll-padding:12px;
}

/* Trade composer */
.modal:has(#modalContent[data-mth-composer="trade"]){
  overflow:hidden!important;
}
#modalContent[data-mth-composer="trade"]{
  min-width:0;
}
#modalContent[data-mth-composer="trade"] .trade-composer-layout,
#modalContent[data-mth-composer="trade"] .trade-composer-grid,
#modalContent[data-mth-composer="trade"] .trade-card-board{
  min-width:0;
}

/* Divider consistency */
.tradehub-detail-section,
.auction-item-detail,
.auction-financial-workflow,
.verify-list{
  border-color:var(--line)!important;
}

/* Tablet */
@media(max-width:900px){
  .modal:has(.tradehub-detail),
  .modal:has(.auction-detail-shell){
    width:calc(100vw - 24px)!important;
    padding:20px!important;
  }
  .tradehub-detail-assets{
    grid-template-columns:1fr;
  }
  .tradehub-detail-requirement{
    grid-template-columns:1fr;
    gap:4px;
  }
  .tradehub-detail-value{
    align-items:flex-start;
    flex-direction:column;
    gap:5px;
  }
  .profile-head{
    row-gap:12px;
  }
}

/* Phone */
@media(max-width:600px){
  .modal:has(.tradehub-detail),
  .modal:has(.auction-detail-shell){
    width:calc(100vw - 12px)!important;
    max-height:calc(100dvh - var(--mth-header-height,62px) - 12px)!important;
    margin:0 auto!important;
    padding:16px!important;
    border-radius:16px!important;
  }
  .tradehub-detail{
    gap:14px;
  }
  .tradehub-detail-head{
    padding-right:34px;
    gap:10px;
  }
  .tradehub-detail-head{
    flex-direction:column;
  }
  .tradehub-detail-head .status{
    align-self:flex-start;
  }
  .tradehub-detail-section{
    padding-top:13px;
  }
  .tradehub-detail-assets{
    gap:8px;
  }
  .tradehub-detail-asset{
    grid-template-columns:36px minmax(0,1fr);
    padding:9px 10px;
  }
  .tradehub-detail-asset-icon{
    width:36px;
    height:36px;
  }
  .tradehub-detail-value{
    padding:11px 12px;
  }
  .tradehub-detail>.modal-actions{
    display:grid;
    grid-template-columns:1fr;
  }
  .tradehub-detail>.modal-actions button{
    width:100%;
  }
  .mth-approx-location-head{
    gap:8px;
  }
  .mth-approx-location-private{
    align-self:flex-start;
  }
  .mth-approx-map{
    min-height:200px;
    height:220px;
  }
  .profile-tabs{
    margin-top:18px;
  }
  .inventory-passport-actions{
    display:grid;
    grid-template-columns:1fr;
  }
  .inventory-passport-actions button{
    width:100%;
    min-width:0;
  }
}


/* Canonical readability scale. This is the final UI layer, so all app surfaces
   inherit one text scale instead of page-specific micro-fonts. */
html{font-size:17px}
body{line-height:1.42}
button,input,select,textarea{line-height:1.25}
.primary,.quiet{min-height:42px}
.primary.small,.quiet.compact{min-height:38px}
.mth-row-actions,.profile-trade-listing-actions,.profile-auction-actions{min-width:0}
.mth-row-actions button,.profile-trade-listing-actions button,.profile-auction-actions button{
  overflow-wrap:anywhere;
}
@media(max-width:720px){
  html{font-size:16px}
  .primary,.quiet{min-height:42px}
}

/* Property editor location clarity */
.asset-entry-section-head{
  display:flex;
  align-items:baseline;
  justify-content:space-between;
  gap:10px;
  flex-wrap:wrap;
  margin:18px 0 10px;
}
.asset-entry-section-head strong{
  font-size:.94rem;
  line-height:1.25;
}
.asset-entry-section-head span{
  color:var(--muted);
  font-size:.8rem;
  line-height:1.4;
}
.asset-map-shortcut{
  margin:10px 0 4px;
  padding:11px 12px;
  border:1px solid var(--line);
  border-radius:12px;
  background:var(--surface-2);
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
}
.asset-map-shortcut>div{
  min-width:0;
  display:flex;
  flex-direction:column;
  gap:2px;
}
.asset-map-shortcut strong{
  font-size:.84rem;
}
.asset-map-shortcut span{
  color:var(--muted);
  font-size:.8rem;
}
.asset-map-shortcut button{
  flex:0 0 auto;
  min-height:34px;
  padding:6px 10px;
  border-radius:8px;
  font-size:.8rem;
}
.asset-location-pin{
  margin-top:18px;
  padding-top:2px;
  border-top:1px solid var(--line);
}
.asset-location-map{
  width:100%;
  height:280px;
  margin-top:8px;
  border:1px solid var(--line);
  border-radius:12px;
  overflow:hidden;
  background:var(--surface-2);
}
.asset-location-controls{
  display:flex;
  gap:8px;
  flex-wrap:wrap;
  margin:10px 0 4px;
}
.asset-location-controls .quiet{
  min-height:34px;
  padding:6px 10px;
  border-radius:8px;
}
@media(max-width:600px){
  .asset-map-shortcut{
    align-items:stretch;
    flex-direction:column;
  }
  .asset-map-shortcut button{width:100%}
  .asset-location-map{height:240px}
}


/* 2026-10-06 — Add/Edit Asset owns a reliable internal scroll region. */
.modal:has(#caTitle){
  width:min(940px,calc(100vw - 32px))!important;
  max-width:940px!important;
  height:min(760px,calc(100dvh - var(--mth-header-height,68px) - 32px))!important;
  max-height:calc(100dvh - var(--mth-header-height,68px) - 32px)!important;
  overflow:hidden!important;
  display:flex!important;
  flex-direction:column!important;
  padding:0!important;
}
.modal:has(#caTitle)>.drawer-close{
  position:absolute!important;
  top:16px!important;
  right:16px!important;
  z-index:20!important;
}
.modal:has(#caTitle)>#modalContent{
  flex:1 1 auto!important;
  min-height:0!important;
  width:100%!important;
  overflow-y:auto!important;
  overflow-x:hidden!important;
  overscroll-behavior:contain!important;
  -webkit-overflow-scrolling:touch!important;
  touch-action:pan-y!important;
  padding:26px 28px 30px!important;
  scrollbar-gutter:stable;
}
.modal:has(#caTitle)>#modalContent::-webkit-scrollbar{width:9px}
.modal:has(#caTitle)>#modalContent::-webkit-scrollbar-track{background:transparent}
.modal:has(#caTitle)>#modalContent::-webkit-scrollbar-thumb{
  background:color-mix(in srgb,var(--muted) 38%,transparent);
  border-radius:999px;
}
.modal:has(#caTitle)>#modalContent>.eyebrow,
.modal:has(#caTitle)>#modalContent>h2{
  padding-right:42px;
}
.modal:has(#caTitle) .modal-actions{
  position:sticky;
  bottom:-30px;
  z-index:8;
  margin:24px -28px -30px!important;
  padding:14px 28px 16px!important;
  border-top:1px solid var(--line);
  background:color-mix(in srgb,var(--surface) 96%,transparent);
  backdrop-filter:blur(10px);
}
.modal:has(#caTitle) .asset-location-map{
  touch-action:pan-x pan-y!important;
}
@media(max-width:720px){
  .modal:has(#caTitle){
    width:calc(100vw - 12px)!important;
    height:calc(100dvh - var(--mth-header-height,62px) - 12px)!important;
    max-height:calc(100dvh - var(--mth-header-height,62px) - 12px)!important;
    margin:0 auto!important;
    border-radius:16px!important;
  }
  .modal:has(#caTitle)>#modalContent{
    padding:20px 16px 24px!important;
  }
  .modal:has(#caTitle) .modal-actions{
    bottom:-24px;
    margin:20px -16px -24px!important;
    padding:12px 16px 14px!important;
  }
}


/* Cash card: canonical asset geometry comes only from asset-card.css. */
.inventory-cash-card .inventory-cash-visual{display:grid;place-items:center}
.inventory-cash-symbol{
  width:58px;height:58px;display:grid;place-items:center;border-radius:50%;
  color:#9c86ff;background:rgba(124,99,255,.10);
  border:1px solid color-mix(in srgb,#9c86ff 28%,var(--line));
  font-family:Manrope,sans-serif;font-size:1.45rem;font-weight:900;
}
@media(max-width:720px){.inventory-cash-symbol{width:50px;height:50px;font-size:1.25rem}}

/* Trade detail: modal shell never clips; content is always the scroll owner. */
.modal:has(.tradehub-detail){
  overflow:hidden!important;
  display:flex!important;
  flex-direction:column!important;
  height:min(760px,calc(100dvh - var(--mth-header-height,68px) - 24px))!important;
  max-height:calc(100dvh - var(--mth-header-height,68px) - 24px)!important;
}
.modal:has(.tradehub-detail)>#modalContent{
  flex:1 1 auto!important;
  min-height:0!important;
  overflow-y:auto!important;
  overflow-x:hidden!important;
  overscroll-behavior:contain!important;
  -webkit-overflow-scrolling:touch!important;
  touch-action:pan-y!important;
  padding-right:8px!important;
  scrollbar-gutter:stable;
}
.modal:has(.tradehub-detail)>#modalContent::-webkit-scrollbar{width:9px}
.modal:has(.tradehub-detail)>#modalContent::-webkit-scrollbar-track{background:transparent}
.modal:has(.tradehub-detail)>#modalContent::-webkit-scrollbar-thumb{
  background:color-mix(in srgb,var(--muted) 38%,transparent);
  border-radius:999px;
}
.modal:has(.tradehub-detail) .mth-approx-map{
  touch-action:pan-x pan-y!important;
}

/* Asset Matching: same reliable internal-scroll behavior as Edit Asset. */
.modal:has(.asset-matching-form){
  width:min(620px,calc(100vw - 32px))!important;
  max-width:620px!important;
  height:min(700px,calc(100dvh - var(--mth-header-height,68px) - 32px))!important;
  max-height:calc(100dvh - var(--mth-header-height,68px) - 32px)!important;
  overflow:hidden!important;
  display:flex!important;
  flex-direction:column!important;
  padding:0!important;
}
.modal:has(.asset-matching-form)>.drawer-close{
  position:absolute!important;
  top:16px!important;
  right:16px!important;
  z-index:20!important;
}
.modal:has(.asset-matching-form)>#modalContent{
  flex:1 1 auto!important;
  min-height:0!important;
  width:100%!important;
  overflow-y:auto!important;
  overflow-x:hidden!important;
  overscroll-behavior:contain!important;
  -webkit-overflow-scrolling:touch!important;
  touch-action:pan-y!important;
  padding:26px 28px 30px!important;
  scrollbar-gutter:stable;
}
.asset-matching-form{
  min-width:0;
}
.asset-matching-form>.eyebrow,
.asset-matching-form>h2{
  padding-right:42px;
}
.asset-matching-form .partner-note{
  margin:0 0 14px!important;
}
.asset-matching-form .field-label{
  display:block;
  margin-top:12px;
  margin-bottom:5px;
}
.asset-matching-form .property-fact-grid{
  gap:10px;
}
.asset-matching-form .modal-actions{
  position:sticky;
  bottom:-30px;
  z-index:8;
  margin:22px -28px -30px!important;
  padding:14px 28px 16px!important;
  border-top:1px solid var(--line);
  background:color-mix(in srgb,var(--surface) 96%,transparent);
  backdrop-filter:blur(10px);
}
@media(max-width:600px){
  .modal:has(.tradehub-detail){
    height:calc(100dvh - var(--mth-header-height,62px) - 12px)!important;
    max-height:calc(100dvh - var(--mth-header-height,62px) - 12px)!important;
  }
  .modal:has(.asset-matching-form){
    width:calc(100vw - 12px)!important;
    height:calc(100dvh - var(--mth-header-height,62px) - 12px)!important;
    max-height:calc(100dvh - var(--mth-header-height,62px) - 12px)!important;
    border-radius:16px!important;
  }
  .modal:has(.asset-matching-form)>#modalContent{
    padding:20px 16px 24px!important;
  }
  .asset-matching-form .modal-actions{
    bottom:-24px;
    margin:20px -16px -24px!important;
    padding:12px 16px 14px!important;
  }
}

/* Canonical readability and overlap safety */
:where(.view,.panel,.card,.asset-card,.tradehub-card,.auction-card,.modal,.drawer,.profile-content,.listing-row,.trade-workspace){min-width:0}:where(.view,.panel,.card,.asset-card,.tradehub-card,.auction-card,.modal,.drawer,.profile-content,.listing-row,.trade-workspace) :where(p,span,strong,small,label,td,th){overflow-wrap:anywhere}:where(.modal-actions,.actions,.card-actions,.listing-actions,.trade-actions,.auction-actions){flex-wrap:wrap;min-width:0}:where(.modal-actions,.actions,.card-actions,.listing-actions,.trade-actions,.auction-actions) button{white-space:normal;max-width:100%}:where(.table-wrap,.table-scroll,.scroll-x){max-width:100%;overflow-x:auto}@media(max-width:720px){:where(.split,.two-col,.detail-grid,.trade-grid,.auction-grid){min-width:0}:where(.modal,.drawer){max-width:calc(100vw - 20px)}}

/* Shared responsive safeguards for Trade, Auction, Inventory and Profile.
   Fix grid min-content pressure at the shared layout source instead of per-card patches. */
:where(.mth-listing-row,.profile-trade-listing,.tradehub-card-main,.tradehub-side,
.tradehub-items,.mth-row-copy,.mth-row-intent,.mth-row-wants,.mth-row-actions,
.auction-detail-shell,.inventory-passport,.profile-head,.profile-stats) {
  min-width:0;
  max-width:100%;
}
.mth-listing-row,
.profile-trade-listing,
.tradehub-card-main,
.tradehub-item,
.tradehub-requirement-item{
  box-sizing:border-box;
}
.mth-row-actions,
.profile-trade-listing-actions{
  display:flex;
  flex-wrap:wrap;
  align-content:center;
  gap:6px;
}
.mth-row-actions>button,
.profile-trade-listing-actions>button{
  min-width:0;
  max-width:100%;
  line-height:1.25;
  overflow-wrap:normal;
  white-space:normal;
}
.tradehub-item .mth-card-name,
.tradehub-cash-item .mth-card-value,
#profileContent .profile-trade-cash-column .mth-card-value{
  white-space:normal!important;
  overflow-wrap:anywhere;
  text-overflow:clip;
  line-height:1.35;
}
#profileContent .profile-trade-listing-body,
#profileContent .profile-trade-listing .tradehub-card-main,
#profileContent .profile-trade-listing .tradehub-card-main.has-profile-cash{
  min-width:0;
}
#profileView .profile-tabs{
  max-width:100%;
  overflow-x:auto;
  overscroll-behavior-x:contain;
}
#profileView .profile-tabs button{
  flex:0 0 auto;
  min-width:0;
}
@media(max-width:760px){
  #profileContent .profile-trade-listing-body{
    grid-template-columns:minmax(0,1fr)!important;
  }
  #profileContent .profile-trade-listing .tradehub-card-main,
  #profileContent .profile-trade-listing .tradehub-card-main.has-profile-cash{
    grid-template-columns:minmax(0,1fr) 30px minmax(0,1fr)!important;
    column-gap:8px!important;
  }
  .mth-row-actions,
  #profileContent .profile-trade-listing-actions{
    width:100%;
    max-width:100%;
    justify-content:flex-start;
  }
  .mth-row-actions button,
  #profileContent .profile-trade-listing-actions button{
    flex:1 1 auto;
    min-height:38px;
  }
  #profileView .profile-tabs{justify-content:flex-start!important}
}
