/* ==========================================================================
   TradeNivo - phone & tablet layer (loaded last). Keeps every page inside the
   screen, header never covers the page title, modern compact cards.
   ========================================================================== */
@media (max-width:1150px){
  /* Inner pages: the header is fixed - leave its height free at the top */
  body.tn-page-inner{padding-top:66px!important}
  body.tn-page-inner .tnmb-hero,body.tn-page-inner .po-hero{margin-top:0!important}
}

@media (max-width:1050px){
  /* Home: grid children may shrink (the category strip scrolls inside its box) */
  .tnh-market>*{min-width:0}
  .tnh-cat-list{-webkit-overflow-scrolling:touch;scroll-snap-type:x proximity;padding-bottom:2px}
  .tnh-cat-list a{scroll-snap-align:start}
  .tnh-cat-list::-webkit-scrollbar{display:none}
}

@media (max-width:760px){
  img{max-width:100%}

  /* Home: trust strip as a compact 2-column grid */
  .tn-exact-trust-strip{display:grid!important;grid-template-columns:1fr 1fr!important;gap:10px!important;padding:14px!important}
  .tn-exact-trust-strip>div{display:grid!important;grid-template-columns:34px 1fr!important;gap:0 8px!important;align-items:center!important;padding:10px!important;background:rgba(255,255,255,.05)!important;border:1px solid rgba(255,255,255,.08)!important;border-radius:12px!important;min-height:0!important}
  .tn-exact-trust-strip>div:last-child{grid-column:1/-1}
  .tn-exact-trust-strip i{grid-row:1/3!important;width:32px!important;height:32px!important;font-size:15px!important}
  .tn-exact-trust-strip b{font-size:13px!important;line-height:1.2!important}
  .tn-exact-trust-strip small{font-size:11.5px!important;line-height:1.3!important}

  /* Sell / buy offer lists: filters behind a button, modern cards */
  .tn-market-shell{padding:0 12px 28px!important;gap:12px!important;margin-top:12px!important}
  .tn-mfilter>summary{display:flex!important}
  .tn-filter-panel{padding:0!important;border-radius:12px!important}
  .tn-filter-panel .tn-mfilter[open]>form{padding:0 14px 14px}
  .tn-list-top{margin:0 0 10px!important;gap:8px;flex-wrap:wrap}
  .tn-list-top span{font-weight:700;color:#0f1d33}
  .tn-sell-card,.tn-offer-card{border-radius:16px!important;margin-bottom:14px!important;box-shadow:0 6px 18px rgba(9,30,66,.06)!important}
  .tn-sell-img{padding:0!important;display:block}
  .tn-sell-img img{width:100%!important;height:200px!important;border-radius:0!important;display:block}
  .tn-offer-main{padding:14px 14px 10px!important}
  .tn-offer-title{flex-wrap:wrap;gap:6px!important;margin-bottom:6px!important}
  .tn-offer-title h3{font-size:18px!important;line-height:1.25!important;flex:1 1 100%;order:-1}
  .tn-offer-desc{font-size:14px!important;margin:0 0 12px!important;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden}
  .tn-offer-metrics{grid-template-columns:1fr 1fr!important;gap:10px 12px!important;background:#f4f7fb;border-radius:12px;padding:10px 12px}
  .tn-offer-metrics b{font-size:14px!important}
  .tn-tags{margin-top:10px!important}
  .tn-company-panel{padding:12px 14px 14px!important;display:grid;grid-template-columns:1fr auto;gap:2px 10px;align-items:center}
  .tn-company-panel h4{font-size:15px!important;margin:0!important;grid-column:1/-1}
  .tn-company-panel p{margin:0!important;font-size:12.5px!important}
  .tn-company-panel .tn-card-actions{grid-column:1/-1;margin-top:10px!important;display:grid!important;grid-template-columns:1fr 1fr;gap:8px!important}
  .tn-card-actions a{padding:12px 8px!important;border-radius:10px!important;font-size:14px!important}

  /* Page heroes: a little tighter */
  .tn-clean-hero-inner{padding:20px 0 18px!important}
  .tn-clean-breadcrumb{margin:10px auto 6px!important;font-size:13px!important}

  /* Offer detail: comfortable spacing, big tap targets */
  .tn-detail-shell{padding-left:12px!important;padding-right:12px!important}
  .tn-request-card{border-radius:16px!important}
  .tn-detail-share{padding:7px 12px!important;font-size:13px!important}

  /* Forms: 16px text stops iPhone from zooming in */
  input,select,textarea{font-size:16px!important}

  /* Chat button a bit smaller so it covers less */
  .chat-toggle{width:54px!important;height:54px!important;font-size:21px!important}
}

/* Filters toggle button (only shown on phones) */
.tn-mfilter>summary{display:none;list-style:none;cursor:pointer;align-items:center;justify-content:space-between;gap:10px;padding:13px 14px;font-weight:800;color:#0f1d33}
.tn-mfilter>summary::-webkit-details-marker{display:none}
.tn-mfilter>summary i.fa-chevron-down{transition:transform .2s}
.tn-mfilter[open]>summary i.fa-chevron-down{transform:rotate(180deg)}
.tn-mfilter>summary em{font-style:normal;background:#087df0;color:#fff;border-radius:999px;padding:2px 9px;font-size:12px;margin-left:6px}

/* Body already leaves room for the fixed header - page boxes don't need their own big top gap */
@media (max-width:1150px){
  body.tn-page-inner .tn-dashboard-shell{margin-top:14px!important}
  body.tn-page-inner .dash-page,body.tn-page-inner .settings-wrap,body.tn-page-inner .public-company-wrap,
  body.tn-page-inner .queries-container,body.tn-page-inner .messages-container,
  body.tn-page-inner .checkout-container,body.tn-page-inner .tn-verification-page{margin-top:18px!important}
}

/* Member dashboard: side menu becomes one swipeable row of chips */
@media (max-width:900px){
  .tn-dashboard-shell{grid-template-columns:minmax(0,1fr)!important;padding:0 12px!important;gap:12px!important;margin-bottom:28px!important}
  .tn-dashboard-sidebar,.tn-dashboard-content{min-width:0!important}
  .tn-dashboard-sidebar{position:sticky!important;top:66px!important;z-index:60!important;margin:0 -12px;overflow:visible!important}
  .tn-dashboard-sidebar-inner{border-radius:0!important;padding:8px 0!important;box-shadow:0 6px 16px rgba(4,18,36,.18)!important}
  .tn-dashboard-sidebar-brand,.tn-dashboard-menu-title{display:none!important}
  .tn-dashboard-menu{display:flex!important;flex-direction:row!important;gap:8px!important;overflow-x:auto;scroll-snap-type:x proximity;-webkit-overflow-scrolling:touch;padding:0 12px;scrollbar-width:none}
  .tn-dashboard-menu::-webkit-scrollbar{display:none}
  .tn-dashboard-menu a{flex:0 0 auto;scroll-snap-align:start;gap:7px!important;padding:8px 13px!important;border-radius:999px!important;font-size:13px!important;background:rgba(255,255,255,.07);white-space:nowrap}
  .tn-dashboard-menu a i{width:auto!important;font-size:13px!important}
  .tn-dashboard-badge{margin-left:2px!important;min-width:18px!important;height:18px!important;font-size:10.5px!important}
}

/* ---------- Home page: app-style phone layout ---------- */
.tn-m-only,.tnh-mbuy{display:none}
.tnhero-btn i{margin-right:8px}
.tnbuy-empty{grid-template-columns:1fr!important;color:#9fd0ff!important;justify-items:center}
@media (max-width:760px){
  /* hero: title, search, 4 action tiles, prices */
  .tnhero .tnhero-in{display:flex;flex-direction:column;padding:18px 0 18px!important;width:calc(100% - 28px)!important}
  .tnhero-grid{display:contents!important}
  .tnhero-copy{display:contents}
  .tnhero-copy h1,.tnhero-copy p{order:1}
  .tnhero-search{order:2;margin:0 0 14px!important;background:#fff!important;border-radius:12px!important;padding:4px 4px 4px 14px!important;box-shadow:0 8px 22px rgba(0,0,0,.25)!important}
  .tnhero-search>i{color:#6d7890!important}
  .tnhero-search input{color:#0f1d33!important;font-size:15px!important}
  .tnhero-search input::placeholder{color:#8792a6!important}
  .tnhero-search button{border-radius:9px!important;width:48px!important;height:40px!important}
  .tnhero-copy h1{font-size:34px!important;margin:4px 0 8px!important}
  .tnhero-copy p{font-size:15px!important;margin:0 0 14px!important;max-width:280px}
  .tnhero-actions{order:3;display:grid!important;grid-template-columns:repeat(4,minmax(0,1fr));gap:8px!important;margin:0}
  .tn-m-only{display:inline-flex}
  .tnhero-btn{flex-direction:column;gap:6px;padding:10px 4px!important;min-height:66px;white-space:normal!important;text-align:center;font-size:11.5px!important;line-height:1.2;border-radius:12px!important;background:rgba(2,13,29,.72)!important;border-color:rgba(255,255,255,.28)!important}
  .tnhero-btn i{margin:0;font-size:18px}
  .tnhero-btn.primary{background:#087df0!important;border-color:#087df0!important}
  .tnhero-btn.green{background:#16a34a!important;border-color:#16a34a!important}
  .tnhero-panel.tnbuy{display:none!important}
  /* LME prices as swipeable cards */
  .tnlme{order:4;margin-top:16px;padding:12px 0 8px!important;background:rgba(4,20,40,.72)!important;border-radius:14px!important}
  .tnlme .tnhero-panel-head{padding:0 12px}
  .tnlme table,.tnlme tbody{display:block}
  .tnlme thead{display:none}
  .tnlme tbody{display:flex;gap:8px;overflow-x:auto;padding:2px 12px 6px;scroll-snap-type:x proximity;scrollbar-width:none}
  .tnlme tbody::-webkit-scrollbar{display:none}
  .tnlme tr{flex:0 0 128px;display:flex;flex-direction:column;gap:3px;scroll-snap-align:start;background:rgba(255,255,255,.07);border:1px solid rgba(255,255,255,.12);border-radius:10px;padding:9px 10px}
  .tnlme td{display:block;border:0!important;padding:0!important;text-align:left!important;white-space:nowrap}
  .tnlme td:first-child{font-size:12px!important;color:#cfe0f5}
  .tnlme td:nth-child(2){font-size:14px!important;font-weight:800}
  .tnlme td:last-child{display:flex;align-items:center;justify-content:space-between;gap:6px}
  .tnlme .tnlme-spark{margin:0}
  .tnlme .tnhero-panel-foot{padding:4px 12px 0;font-size:10.5px;font-weight:600;color:#9fb3c8}

  /* trust strip isn't needed on phones (same points appear lower down) */
  .tn-exact-trust-strip{display:none!important}

  /* categories: photo tiles in one swipe row */
  .tnh-wrap{margin-top:16px!important}
  .tnh-cats{background:none!important;box-shadow:none!important;padding:0!important;color:#0f1d33!important}
  .tnh-cats h2{color:#0f1d33!important;font-size:19px!important;text-transform:none!important;letter-spacing:0!important;padding:0!important;margin:0 0 10px!important}
  .tnh-cat-list{display:flex!important;gap:10px!important;overflow-x:auto;padding-bottom:4px}
  .tnh-cat-list a{flex:0 0 104px!important;flex-direction:column;align-items:stretch!important;gap:0!important;padding:0!important;background:#fff!important;border:1px solid #e3ebf7;border-radius:12px!important;overflow:hidden;color:#0f1d33!important;font-size:12.5px!important;font-weight:700!important;box-shadow:0 4px 12px rgba(9,30,66,.06)}
  .tnh-cat-list a img{width:100%!important;height:70px!important;border-radius:0!important;object-fit:cover;margin:0!important}
  .tnh-cat-list a span{padding:7px 8px;line-height:1.2;white-space:normal}
  .tnh-cat-list a i{display:none}
  .tnh-cat-list a.active{border-color:#087df0;box-shadow:0 0 0 2px #087df0 inset}
  .tnh-cats-all,.tnh-help{display:none!important}
  .tnh-head h2{font-size:19px!important;text-transform:none!important;letter-spacing:0!important;display:flex;align-items:center;gap:8px}
  .tnh-head a{font-size:13.5px!important}

  /* offer cards: at most two "open slot" cards */
  .tnh-offer-empty~.tnh-offer-empty~.tnh-offer-empty{display:none!important}

  /* promo: compact banner */
  .tnh-promo{grid-template-columns:56px 1fr!important;text-align:left!important;gap:12px!important;padding:18px 14px!important;background:linear-gradient(120deg,#062a5c,#0a4fa8)!important;border:0!important;border-radius:16px!important;color:#fff}
  .tnh-promo-icon{width:56px!important;height:56px!important;font-size:22px!important;margin:0!important}
  .tnh-promo small{color:#9fd0ff!important}
  .tnh-promo h3{color:#fff!important;font-size:20px!important;margin:2px 0 4px!important}
  .tnh-promo p{color:#dbe7f5!important;font-size:13px!important;margin:0 0 10px!important}
  .tnh-promo .btn{padding:10px 16px!important;font-size:14px!important}
  .tnh-promo-feats{grid-column:1/-1;display:grid!important;grid-template-columns:1fr 1fr!important;gap:8px!important}
  .tnh-promo-feats div{display:flex!important;align-items:center;gap:8px;padding:8px!important;border:0!important;background:rgba(255,255,255,.08);border-radius:10px;text-align:left!important}
  .tnh-promo-feats i{width:28px!important;height:28px!important;font-size:13px!important;margin:0!important;flex:0 0 28px}
  .tnh-promo-feats b{color:#fff!important;font-size:12.5px!important}
  .tnh-promo-feats span{display:none!important}
  .tnh-ribbon{font-size:10px!important}

  /* live buying offers (under the promo): auto-scrolling table */
  .tnh-mbuy{display:block;margin-top:22px}
  .tnh-mbuy .tnh-head{display:flex;justify-content:space-between;align-items:center;margin-bottom:10px}
  .tnh-mbt{background:#fff;border:1px solid #dfe8f4;border-radius:16px;overflow:hidden;box-shadow:0 8px 22px rgba(9,30,66,.07)}
  .tnh-mbt-head,.tnh-mbt-row{display:grid;grid-template-columns:minmax(0,1.5fr) minmax(0,1.15fr) minmax(0,.8fr) minmax(0,1fr) minmax(0,.62fr);gap:6px;align-items:center;padding:0 12px}
  .tnh-mbt-head{background:#0b2a55;color:#dbe7f5;font-size:10.5px;font-weight:800;padding-top:10px;padding-bottom:10px}
  .tnh-mbt-head span:nth-child(n+3),.tnh-mbt-row span:nth-child(n+3){text-align:right}
  .tnh-mbt-view{--h:44px;overflow:hidden}
  .tnh-mbt-view.is-scrolling{height:calc(var(--h) * 4)}
  .tnh-mbt-row{height:var(--h);box-sizing:border-box;border-bottom:1px solid #edf2f8;color:#0f1d33;text-decoration:none;font-size:12.5px}
  .tnh-mbt-row span{white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
  .tnh-mbt-row span:first-child{font-weight:700}
  .tnh-mbt-row span:nth-child(2){color:#56627a}
  .tnh-mbt-row .p{color:#16a34a;font-weight:800}
  .tnh-mbt-row .o{color:#087df0;font-weight:800}
  .tnh-mbt-row:nth-child(even){background:#f8fbff}
  .tnh-mbt-view.is-scrolling .tnh-mbt-track{animation:tnhMbt calc(var(--rows) * 3s) linear infinite}
  .tnh-mbt-view.is-scrolling:hover .tnh-mbt-track,.tnh-mbt-view.is-scrolling:active .tnh-mbt-track{animation-play-state:paused}
  .tnh-mbt-all{display:flex;justify-content:center;align-items:center;gap:8px;padding:12px;font-weight:800;font-size:14px;color:#087df0;text-decoration:none;border-top:1px solid #edf2f8}
  .tnh-mbuy-empty{display:block;text-align:center;padding:16px;margin:12px;border:1px dashed #9cc7f5;border-radius:12px;color:#087df0;font-weight:700;text-decoration:none}

  /* how it works: 2 x 2 */
  .tnh-how h2{font-size:21px!important}
  .tnh-steps{grid-template-columns:1fr 1fr!important;gap:10px!important}
  .tnh-step{padding:12px 10px!important;border-radius:12px!important}
  .tnh-step b{font-size:14px!important}
  .tnh-step span{font-size:12px!important}

  /* numbers: 3 per row */
  .tnh-stats{grid-template-columns:repeat(3,1fr)!important;gap:12px 4px!important;padding:14px 6px!important}
  .tnh-stats div{display:flex!important;flex-direction:column;align-items:center;text-align:center;padding:0 2px!important;border:0!important}
  .tnh-stats i{width:36px!important;height:36px!important;font-size:15px!important;margin-bottom:4px}
  .tnh-stats b,.tnh-stats span{align-self:center!important}
  .tnh-stats b{font-size:18px!important}
  .tnh-stats span{font-size:11px!important;line-height:1.2}
  .tnh-strip{display:none!important}
}

/* ---------- Bottom app menu (phones) ---------- */
.tn-bottom-nav{display:none}
@media (max-width:760px){
  .tn-bottom-nav{display:grid;grid-template-columns:repeat(6,1fr);position:fixed;left:0;right:0;bottom:0;z-index:90;background:#061224;border-top:1px solid rgba(255,255,255,.08);padding:6px 2px calc(6px + env(safe-area-inset-bottom));box-shadow:0 -6px 20px rgba(4,18,36,.25)}
  .tn-bottom-nav a{display:flex;flex-direction:column;align-items:center;gap:3px;color:rgba(255,255,255,.7);text-decoration:none;font-size:10.5px;font-weight:700;padding:3px 0;white-space:nowrap}
  .tn-bottom-nav a i{font-size:18px}
  .tn-bottom-nav a.active{color:#2f9bff}
  body{padding-bottom:calc(62px + env(safe-area-inset-bottom))!important}
  .chat-widget{bottom:calc(74px + env(safe-area-inset-bottom))!important;right:14px!important}
}

@keyframes tnhMbt{from{transform:translateY(0)}to{transform:translateY(-50%)}}
@media (prefers-reduced-motion:reduce){.tnh-mbt-view.is-scrolling{overflow-y:auto}.tnh-mbt-view.is-scrolling .tnh-mbt-track{animation:none}}

/* Home: offers come in rows of 7 (.tnh-orow). Desktop ignores the rows and keeps its grid (5 / 4 / 3 cards a row);
   phones show rows that each swipe (and slide by themselves) on their own. 3 to 5 rows, depending on the number of
   offers: cards beyond the shown rows carry hd / ht / hs / hm (desktop / tablet / small tablet / phone). */
.tnh-orow{display:contents}
@media (min-width:1181px){.tnh-offers .tnh-offer.hd{display:none!important}}
@media (max-width:1180px) and (min-width:861px){.tnh-offers .tnh-offer.ht{display:none!important}}
@media (max-width:860px) and (min-width:761px){.tnh-offers .tnh-offer.hs{display:none!important}}
@media (max-width:760px){.tnh-offers .tnh-orow-xm,.tnh-offers .tnh-orow>.tnh-offer.hm{display:none!important}}
@media (max-width:760px){
  .tnh-offers:not(.is-all){display:flex!important;flex-direction:column;gap:12px!important}
  .tnh-orow{display:flex;gap:10px;overflow-x:auto;scroll-snap-type:x mandatory;scroll-behavior:smooth;padding:2px 2px 4px;scrollbar-width:none}
  .tnh-orow::-webkit-scrollbar{display:none}
  .tnh-orow>.tnh-offer{flex:0 0 calc(50% - 5px);scroll-snap-align:start;display:flex!important;box-sizing:border-box;min-width:0}
}

