/* Markets page (#/markets): restyled to match the uploaded Lend & Borrow design.
   Scoped to the markets route, so other pages are not affected. The data and columns are the site's live ones. */

html[data-nav-route="market"] {
  --m-bg: #f3efe6; --m-raised: #fcfbf7; --m-sunken: #e9e4d8;
  --m-border: #e2ddcf; --m-border-strong: #cfc8b5;
  --m-text: #17140f; --m-muted: #59544a; --m-subtle: #938d7e;
  --m-accent: #0b42e8; --m-accent-soft: #e8edff; --m-pos: #1a8c4a;
  --m-shadow: 0 1px 2px rgba(15,20,23,.05), 0 10px 30px -14px rgba(15,20,23,.14);
  --m-sans: Inter, system-ui, sans-serif; --m-mono: "JetBrains Mono", ui-monospace, monospace; --m-serif: Fraunces, Georgia, serif;
}
html[data-nav-route="market"][data-theme="dark"] {
  --m-bg: #0d0e11; --m-raised: #16181d; --m-sunken: #1d2026;
  --m-border: #2a2d35; --m-border-strong: #3a3e48;
  --m-text: #f2f0ea; --m-muted: #a7a79e; --m-subtle: #6f6f69;
  --m-accent: #4d7bff; --m-accent-soft: #1a2440; --m-pos: #3fcf7b;
  --m-shadow: 0 1px 2px rgba(0,0,0,.5), 0 10px 30px -14px rgba(0,0,0,.7);
}

/* page and heading */
html[data-nav-route="market"] body.app-mode:not(.stock-detail-mode) #appView { background: var(--m-bg); color: var(--m-text); }
html[data-nav-route="market"] body.app-mode:not(.stock-detail-mode) #appView .app-heading { padding-top: clamp(28px, 4vw, 48px); }
html[data-nav-route="market"] body.app-mode:not(.stock-detail-mode) #appView .section-label { font: 600 12px/1.2 var(--m-mono); letter-spacing: .14em; text-transform: uppercase; color: var(--m-accent); }
html[data-nav-route="market"] body.app-mode:not(.stock-detail-mode) #appTitle { font-family: var(--m-serif); font-weight: 400; font-size: clamp(2.2rem, 4.6vw, 3.25rem); line-height: 1.05; letter-spacing: -.02em; color: var(--m-text); margin-top: 10px; }
html[data-nav-route="market"] body.app-mode:not(.stock-detail-mode) #appSubtitle { font-family: var(--m-sans); font-size: clamp(1rem, 1.4vw, 1.125rem); color: var(--m-muted); margin-top: 8px; }
html[data-nav-route="market"] body.app-mode:not(.stock-detail-mode) [hidden] { display: none !important; }

/* stats */
html[data-nav-route="market"] body.app-mode:not(.stock-detail-mode) #lendBorrowSummary { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin: 24px 0; }
html[data-nav-route="market"] body.app-mode:not(.stock-detail-mode) .lend-borrow-stat { background: var(--m-raised); border: 1px solid var(--m-border); border-radius: 12px; padding: 16px 18px; box-shadow: none; }
html[data-nav-route="market"] body.app-mode:not(.stock-detail-mode) .lend-borrow-stat span { display: block; font: 600 11px/1.3 var(--m-mono); letter-spacing: .08em; text-transform: uppercase; color: var(--m-subtle); }
html[data-nav-route="market"] body.app-mode:not(.stock-detail-mode) .lend-borrow-stat strong { display: block; margin-top: 6px; font: 600 24px/1.1 var(--m-mono); color: var(--m-text); font-variant-numeric: tabular-nums; }

/* toolbar */
html[data-nav-route="market"] body.app-mode:not(.stock-detail-mode) .market-toolbar { display: grid; gap: 12px; }
html[data-nav-route="market"] body.app-mode:not(.stock-detail-mode) .explore-switch { display: inline-flex; width: auto; background: var(--m-sunken); border-radius: 999px; padding: 4px; }
html[data-nav-route="market"] body.app-mode:not(.stock-detail-mode) .explore-switch button { padding: 10px 24px; border-radius: 999px; font: 600 14px var(--m-sans); color: var(--m-muted); background: transparent; border: 0; }
html[data-nav-route="market"] body.app-mode:not(.stock-detail-mode) .explore-switch button.on { background: var(--m-raised); color: var(--m-text); box-shadow: var(--m-shadow); }
html[data-nav-route="market"] body.app-mode:not(.stock-detail-mode) .toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
html[data-nav-route="market"] body.app-mode:not(.stock-detail-mode) .search-wrap { flex: 1 1 220px; min-width: 0; height: 46px; border: 1px solid var(--m-border); border-radius: 999px; background: var(--m-raised); padding: 0 16px; }
html[data-nav-route="market"] body.app-mode:not(.stock-detail-mode) .search-wrap input { background: transparent; color: var(--m-text); font: 400 15px var(--m-sans); }
html[data-nav-route="market"] body.app-mode:not(.stock-detail-mode) #marketSort,
html[data-nav-route="market"] body.app-mode:not(.stock-detail-mode) #marketLiquidityFilter,
html[data-nav-route="market"] body.app-mode:not(.stock-detail-mode) #refresh.refresh { height: 46px; border: 1px solid var(--m-border); border-radius: 999px; background: var(--m-raised); color: var(--m-text); padding: 0 16px; font: 500 14px var(--m-sans); }

/* table card */
html[data-nav-route="market"] body.app-mode:not(.stock-detail-mode) #marketlist { background: var(--m-raised); border: 1px solid var(--m-border); border-radius: 14px; box-shadow: var(--m-shadow); overflow: hidden; }
html[data-nav-route="market"] body.app-mode:not(.stock-detail-mode) #marketlist table.table thead th { font: 600 11px/1.3 var(--m-mono); letter-spacing: .06em; text-transform: uppercase; color: var(--m-subtle); background: var(--m-sunken); padding: 14px; border-bottom: 1px solid var(--m-border); white-space: nowrap; }
html[data-nav-route="market"] body.app-mode:not(.stock-detail-mode) #marketlist table.table tbody td { padding: 16px 14px; border-top: 1px solid var(--m-border); color: var(--m-text); font: 500 14px var(--m-mono); vertical-align: middle; }
html[data-nav-route="market"] body.app-mode:not(.stock-detail-mode) #marketlist table.table tbody td:first-child { font-family: var(--m-sans); }
html[data-nav-route="market"] body.app-mode:not(.stock-detail-mode) #marketlist .rate-focus { color: var(--m-accent); }
html[data-nav-route="market"] body.app-mode:not(.stock-detail-mode) #marketlist td.apy { color: var(--m-pos); }
html[data-nav-route="market"] body.app-mode:not(.stock-detail-mode) #marketlist .asset { display: flex; align-items: center; gap: 12px; }
html[data-nav-route="market"] body.app-mode:not(.stock-detail-mode) #marketlist .asset strong { display: block; font: 600 15px/1.25 var(--m-sans); color: var(--m-text); }
html[data-nav-route="market"] body.app-mode:not(.stock-detail-mode) #marketlist .asset strong a { color: inherit; }
html[data-nav-route="market"] body.app-mode:not(.stock-detail-mode) #marketlist .asset small { display: block; margin-top: 2px; font: 500 12px var(--m-mono); color: var(--m-subtle); letter-spacing: .02em; }
html[data-nav-route="market"] body.app-mode:not(.stock-detail-mode) #marketlist .coin { width: 36px; height: 36px; border-radius: 50%; background: var(--m-sunken); border: 1px solid var(--m-border); display: grid; place-items: center; flex: none; overflow: hidden; }
html[data-nav-route="market"] body.app-mode:not(.stock-detail-mode) #marketlist .coin img { width: 22px; height: 22px; object-fit: contain; }
html[data-nav-route="market"] body.app-mode:not(.stock-detail-mode) #marketlist .market-utilization { display: block; width: 88px; height: 5px; margin-top: 6px; border-radius: 999px; background: var(--m-sunken); overflow: hidden; }
html[data-nav-route="market"] body.app-mode:not(.stock-detail-mode) #marketlist .market-utilization-fill { display: block; height: 100%; background: var(--m-pos); border-radius: 999px; }
html[data-nav-route="market"] body.app-mode:not(.stock-detail-mode) #marketlist .sc-status { display: inline-flex; align-items: center; margin-left: 8px; height: 22px; padding: 0 9px; border-radius: 999px; font: 600 11px var(--m-mono); background: color-mix(in srgb, var(--m-pos) 14%, transparent); color: var(--m-pos); }
html[data-nav-route="market"] body.app-mode:not(.stock-detail-mode) #marketlist .market-row-action { display: inline-flex; align-items: center; height: 34px; padding: 0 16px; border-radius: 999px; background: var(--m-accent-soft); color: var(--m-accent); font: 600 13px var(--m-sans); transition: background .12s, color .12s; }
html[data-nav-route="market"] body.app-mode:not(.stock-detail-mode) #marketlist .market-row-action:hover { background: var(--m-accent); color: #fff; }

/* phones: each market becomes a compact card */
@media (max-width: 760px) {
  html[data-nav-route="market"] body.app-mode:not(.stock-detail-mode) #lendBorrowSummary { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  html[data-nav-route="market"] body.app-mode:not(.stock-detail-mode) .lend-borrow-stat { padding: 14px; }
  html[data-nav-route="market"] body.app-mode:not(.stock-detail-mode) .lend-borrow-stat strong { font-size: 20px; }
  html[data-nav-route="market"] body.app-mode:not(.stock-detail-mode) .toolbar .search-wrap { flex-basis: 100%; }
  html[data-nav-route="market"] body.app-mode:not(.stock-detail-mode) #marketlist { background: transparent; border: 0; box-shadow: none; overflow: visible; }
  html[data-nav-route="market"] body.app-mode:not(.stock-detail-mode) #marketlist table.table thead { display: none; }
  html[data-nav-route="market"] body.app-mode:not(.stock-detail-mode) #marketlist table.table,
  html[data-nav-route="market"] body.app-mode:not(.stock-detail-mode) #marketlist table.table tbody,
  html[data-nav-route="market"] body.app-mode:not(.stock-detail-mode) #marketlist table.table tr,
  html[data-nav-route="market"] body.app-mode:not(.stock-detail-mode) #marketlist table.table td { display: block; width: 100%; }
  html[data-nav-route="market"] body.app-mode:not(.stock-detail-mode) #marketlist table.table tr { background: var(--m-raised); border: 1px solid var(--m-border); border-radius: 14px; padding: 14px; margin-bottom: 10px; box-shadow: var(--m-shadow); }
  html[data-nav-route="market"] body.app-mode:not(.stock-detail-mode) #marketlist table.table td { display: flex; justify-content: space-between; align-items: center; gap: 12px; border: 0; padding: 6px 0; text-align: right; }
  html[data-nav-route="market"] body.app-mode:not(.stock-detail-mode) #marketlist table.table td:first-child { justify-content: flex-start; padding-bottom: 12px; border-bottom: 1px solid var(--m-border); margin-bottom: 6px; }
  html[data-nav-route="market"] body.app-mode:not(.stock-detail-mode) #marketlist table.table td[data-label]::before { content: attr(data-label); color: var(--m-subtle); font: 500 12px var(--m-sans); text-align: left; }
  html[data-nav-route="market"] body.app-mode:not(.stock-detail-mode) #marketlist table.table td:last-child { justify-content: flex-end; padding-top: 10px; }
}

/* Colours and type are forced here because the older markets styles use !important. */
html[data-nav-route="market"] body.app-mode:not(.stock-detail-mode) #appView .lend-borrow-stat { background: var(--m-raised) !important; border-color: var(--m-border) !important; }
html[data-nav-route="market"] body.app-mode:not(.stock-detail-mode) #appView .lend-borrow-stat span { color: var(--m-subtle) !important; font-family: var(--m-mono) !important; }
html[data-nav-route="market"] body.app-mode:not(.stock-detail-mode) #appView .lend-borrow-stat strong { color: var(--m-text) !important; font-family: var(--m-mono) !important; }
html[data-nav-route="market"] body.app-mode:not(.stock-detail-mode) #appView .explore-switch { background: var(--m-sunken) !important; }
html[data-nav-route="market"] body.app-mode:not(.stock-detail-mode) #appView .explore-switch button { color: var(--m-muted) !important; background: transparent !important; }
html[data-nav-route="market"] body.app-mode:not(.stock-detail-mode) #appView .explore-switch button.on { background: var(--m-raised) !important; color: var(--m-text) !important; }
html[data-nav-route="market"] body.app-mode:not(.stock-detail-mode) #appView .search-wrap { background: var(--m-raised) !important; border-color: var(--m-border) !important; }
html[data-nav-route="market"] body.app-mode:not(.stock-detail-mode) #appView .search-wrap input { color: var(--m-text) !important; }
html[data-nav-route="market"] body.app-mode:not(.stock-detail-mode) #appView #marketSort, html[data-nav-route="market"] body.app-mode:not(.stock-detail-mode) #appView #marketLiquidityFilter, html[data-nav-route="market"] body.app-mode:not(.stock-detail-mode) #appView #refresh.refresh { background: var(--m-raised) !important; border-color: var(--m-border) !important; color: var(--m-text) !important; }
html[data-nav-route="market"] body.app-mode:not(.stock-detail-mode) #appView #marketlist { background: var(--m-raised) !important; border-color: var(--m-border) !important; }
html[data-nav-route="market"] body.app-mode:not(.stock-detail-mode) #appView #marketlist table.table thead th { background: var(--m-sunken) !important; color: var(--m-subtle) !important; font-family: var(--m-mono) !important; border-color: var(--m-border) !important; }
html[data-nav-route="market"] body.app-mode:not(.stock-detail-mode) #appView #marketlist table.table tbody td { color: var(--m-text) !important; border-color: var(--m-border) !important; font-family: var(--m-mono) !important; }
html[data-nav-route="market"] body.app-mode:not(.stock-detail-mode) #appView #marketlist table.table tbody td:first-child { font-family: var(--m-sans) !important; }
html[data-nav-route="market"] body.app-mode:not(.stock-detail-mode) #appView #marketlist .rate-focus { color: var(--m-accent) !important; }
html[data-nav-route="market"] body.app-mode:not(.stock-detail-mode) #appView #marketlist td.apy { color: var(--m-pos) !important; }
html[data-nav-route="market"] body.app-mode:not(.stock-detail-mode) #appView #marketlist .market-row-action { background: var(--m-accent-soft) !important; color: var(--m-accent) !important; }
html[data-nav-route="market"] body.app-mode:not(.stock-detail-mode) #appView #marketlist .market-row-action:hover { background: var(--m-accent) !important; color: #fff !important; }
html[data-nav-route="market"] body.app-mode:not(.stock-detail-mode) #appView #marketlist .asset strong, html[data-nav-route="market"] body.app-mode:not(.stock-detail-mode) #appView #marketlist .asset strong a { color: var(--m-text) !important; }
html[data-nav-route="market"] body.app-mode:not(.stock-detail-mode) #appView #marketlist .asset small { color: var(--m-subtle) !important; }
html[data-nav-route="market"] body.app-mode:not(.stock-detail-mode) #appView #marketlist .asset strong a { border: 0 !important; padding: 0 !important; background: none !important; box-shadow: none !important; display: inline !important; }
/* phones: keep every header item reachable; nav links move to a scrolling second row */
@media (max-width: 760px) {
  html[data-nav-route="market"] body.app-mode:not(.stock-detail-mode) .site-header { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; }
  html[data-nav-route="market"] body.app-mode:not(.stock-detail-mode) .site-header .brand-link { order: 1; }
  html[data-nav-route="market"] body.app-mode:not(.stock-detail-mode) .site-header .site-nav { order: 3; flex: 1 1 100%; min-width: 0; overflow-x: auto; white-space: nowrap; scrollbar-width: none; }
  html[data-nav-route="market"] body.app-mode:not(.stock-detail-mode) .site-header .site-nav::-webkit-scrollbar { display: none; }
  html[data-nav-route="market"] body.app-mode:not(.stock-detail-mode) .site-header #siteLanguage { display: none; }
  html[data-nav-route="market"] body.app-mode:not(.stock-detail-mode) #appView { padding-left: 16px; padding-right: 16px; }
}
/* phones: each market is a two-column card. Asset on top, then rate, available, max LTV, and the action. */
@media (max-width: 760px) {
  html[data-nav-route="market"] body.app-mode:not(.stock-detail-mode) #appView #marketlist table.table tbody tr { display: grid !important; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px; padding: 14px; }
  html[data-nav-route="market"] body.app-mode:not(.stock-detail-mode) #appView #marketlist table.table tbody td { width: auto !important; min-width: 0; display: grid !important; gap: 4px; justify-items: start; align-content: start; padding: 0 !important; border: 0 !important; text-align: left !important; }
  html[data-nav-route="market"] body.app-mode:not(.stock-detail-mode) #appView #marketlist table.table tbody td:first-child { grid-column: 1 / -1; grid-row: 1; padding-bottom: 12px !important; border-bottom: 1px solid var(--m-border) !important; }
  html[data-nav-route="market"] body.app-mode:not(.stock-detail-mode) #appView #marketlist table.table tbody td:nth-child(2) { grid-column: 1; grid-row: 2; }
  html[data-nav-route="market"] body.app-mode:not(.stock-detail-mode) #appView #marketlist table.table tbody td:nth-child(3) { grid-column: 2; grid-row: 2; }
  html[data-nav-route="market"] body.app-mode:not(.stock-detail-mode) #appView #marketlist table.table tbody td:nth-child(4) { grid-column: 1; grid-row: 3; }
  html[data-nav-route="market"] body.app-mode:not(.stock-detail-mode) #appView #marketlist table.table tbody td:nth-child(6) { grid-column: 2; grid-row: 3; }
  html[data-nav-route="market"] body.app-mode:not(.stock-detail-mode) #appView #marketlist table.table tbody td:last-child { grid-column: 1 / -1; grid-row: 4; padding-top: 6px !important; }
  html[data-nav-route="market"] body.app-mode:not(.stock-detail-mode) #appView #marketlist table.table tbody td[data-label]::before { content: attr(data-label); font: 500 11px/1.2 var(--m-sans); letter-spacing: .04em; text-transform: uppercase; color: var(--m-subtle); }
  html[data-nav-route="market"] body.app-mode:not(.stock-detail-mode) #appView #marketlist table.table tbody td:last-child .market-row-action { width: 100%; justify-content: center; height: 40px; }
  html[data-nav-route="market"] body.app-mode:not(.stock-detail-mode) #appView #marketlist table.table tbody td:last-child .sc-expand { display: none !important; }
  html[data-nav-route="market"] body.app-mode:not(.stock-detail-mode) #appView #marketlist table.table #marketlist .market-utilization { margin-top: 4px; }
}
@media (max-width: 760px) {
  html[data-nav-route="market"] body.app-mode:not(.stock-detail-mode) #appView #marketlist table.table tbody td[hidden] { display: none !important; }
}
@media (min-width: 761px) and (max-width: 1100px) {
  html[data-nav-route="market"] body.app-mode:not(.stock-detail-mode) #appView #marketlist .table-scroll { overflow-x: auto; }
  html[data-nav-route="market"] body.app-mode:not(.stock-detail-mode) #appView #marketlist table.table thead th, html[data-nav-route="market"] body.app-mode:not(.stock-detail-mode) #appView #marketlist table.table tbody td { padding-left: 10px !important; padding-right: 10px !important; }
}
/* Keep the existing site header. At tablet widths, let its links scroll together. */
@media (max-width: 900px) {
  html[data-nav-route="market"] body.app-mode:not(.stock-detail-mode) .site-header { display: flex; flex-wrap: wrap; gap: 8px; padding-bottom: 8px; }
  html[data-nav-route="market"] body.app-mode:not(.stock-detail-mode) .site-header .header-left { display: contents; }
  html[data-nav-route="market"] body.app-mode:not(.stock-detail-mode) .site-header .brand-link { order: 1; }
  html[data-nav-route="market"] body.app-mode:not(.stock-detail-mode) .site-header .header-actions { order: 2; margin-left: auto; }
  html[data-nav-route="market"] body.app-mode:not(.stock-detail-mode) .site-header .site-nav { order: 3; flex: 1 1 100%; display: flex; overflow-x: auto; white-space: nowrap; justify-content: flex-start; }
  html[data-nav-route="market"] body.app-mode:not(.stock-detail-mode) .site-header .site-nav a { flex: 0 0 auto; width: auto; min-width: 0; padding: 8px 12px; }
}

/* Reference-style market controls, wired to the existing live filters. */
@media(max-width:760px){
  html[data-nav-route="market"] body.app-mode:not(.stock-detail-mode) #appView #marketlist {background:transparent!important;border:0!important;box-shadow:none!important}
  html[data-nav-route="market"] body.app-mode:not(.stock-detail-mode) #appView #marketlist .table-scroll {padding:0!important;background:transparent!important;border:0!important;box-shadow:none!important;overflow:visible!important}
  html[data-nav-route="market"] body.app-mode:not(.stock-detail-mode) #appView #marketlist table.table {display:block!important;min-width:0!important;background:transparent!important}
  html[data-nav-route="market"] body.app-mode:not(.stock-detail-mode) #appView #marketlist table.table thead {display:none!important}
  html[data-nav-route="market"] body.app-mode:not(.stock-detail-mode) #appView #marketlist table.table tbody {display:block!important}
  html[data-nav-route="market"] body.app-mode:not(.stock-detail-mode) #appView #marketlist table.table tbody tr:not([hidden]) {background:var(--m-raised)!important}
  html[data-nav-route="market"] body.app-mode:not(.stock-detail-mode) #appView #marketlist table.table tbody td {background:transparent!important}
}

/* Match the reference page width and type scale on both market routes. */
html[data-nav-route="market"] body.app-mode {background:var(--m-bg)}
html[data-nav-route="market"] body.app-mode #appView {
  box-sizing:border-box!important;width:100%!important;max-width:1180px!important;
  margin-left:auto!important;margin-right:auto!important;
  padding-left:24px!important;padding-right:24px!important;
}
html[data-nav-route="market"] body.app-mode:not(.stock-detail-mode) #appView #appTitle {
  font-size:clamp(30px,4vw,40px)!important;line-height:1.05!important;
}
html[data-nav-route="market"] body.app-mode:not(.stock-detail-mode) #appView .lend-borrow-stat strong {
  font-size:20px!important;
}
html[data-nav-route="market"] body.app-mode.stock-detail-mode #appView .layout {
  grid-template-columns:minmax(0,1fr) minmax(420px,500px)!important;gap:28px!important;
}
html[data-nav-route="market"] body.app-mode.stock-detail-mode #appView #marketOverview .market-identity h1 {
  font-family:Inter,system-ui,sans-serif!important;font-size:28px!important;font-weight:600!important;
}
html[data-nav-route="market"] body.app-mode:not(.stock-detail-mode) #appView #marketlist .asset strong a {font-family:var(--m-mono)!important;font-size:14px!important;font-weight:600!important}
html[data-nav-route="market"] body.app-mode:not(.stock-detail-mode) #appView #marketlist .asset small {font-family:var(--m-sans)!important;font-size:12px!important;letter-spacing:0!important}
html[data-nav-route="market"] body.app-mode:not(.stock-detail-mode) #appView #marketlist .sc-status {display:none!important}
html[data-nav-route="market"] body.app-mode:not(.stock-detail-mode) #appView #stockListPanel {
  border:0!important;box-shadow:none!important;margin:24px 0 16px!important;padding:0!important;
}
html[data-nav-route="market"] body.app-mode:not(.stock-detail-mode) #appView #marketlist {
  border-radius:26px!important;padding:8px 24px 24px!important;overflow:hidden!important;
}
html[data-nav-route="market"] body.app-mode:not(.stock-detail-mode) #appView #marketlist .table-scroll {
  border:0!important;border-radius:0!important;padding:0!important;
  background:transparent!important;box-shadow:none!important;
}
html[data-nav-route="market"] body.app-mode:not(.stock-detail-mode) #appView #marketlist .table thead th {
  background:transparent!important;
}
@media(max-width:760px){
  html[data-nav-route="market"] body.app-mode:not(.stock-detail-mode) #appView #marketlist {padding:0!important;border:0!important;overflow:visible!important}
}
@media(max-width:920px){
  html[data-nav-route="market"] body.app-mode.stock-detail-mode #appView .layout {grid-template-columns:1fr!important}
}
@media(max-width:560px){
  html[data-nav-route="market"] body.app-mode.stock-detail-mode #appView {
    padding-left:12px!important;padding-right:12px!important;
  }
  html[data-nav-route="market"] body.app-mode.stock-detail-mode #appView #details .balance-row {
    flex-wrap:wrap;gap:4px 10px;
  }
  html[data-nav-route="market"] body.app-mode.stock-detail-mode #appView #form .position-summary > div {
    gap:10px;
  }
  html[data-nav-route="market"] body.app-mode.stock-detail-mode #appView #form .position-summary > div > :last-child {
    text-align:right;overflow-wrap:anywhere;
  }
}

/* Market page: two options only (Borrow and Lend). Repay and Withdraw tabs are hidden. */
html[data-nav-route="market"] .tabs { display: grid !important; grid-template-columns: 1fr 1fr !important; }
html[data-nav-route="market"] .tabs > button#rt,
html[data-nav-route="market"] .tabs > button#wt { display: none !important; }
/* Market form: inner Borrow | Repay switch, styled like the outer switch. */
html[data-nav-route="market"] .mf-inner { display: flex; background: var(--m-sunken); border-radius: 999px; padding: 4px; margin: 0 0 18px; }
html[data-nav-route="market"] .mf-inner button { flex: 1; height: 40px; border-radius: 999px; border: 0; background: transparent; color: var(--m-muted); font: 600 14px var(--m-sans); cursor: pointer; }
html[data-nav-route="market"] .mf-inner button.on { background: var(--m-raised); color: var(--m-text); box-shadow: var(--m-shadow); }
/* Market form: Target LTV slider. */
html[data-nav-route="market"] .mf-ltv { margin: 14px 0; display: grid; gap: 8px; }
html[data-nav-route="market"] .mf-ltv-head { display: flex; justify-content: space-between; align-items: baseline; font: 500 14px var(--m-sans); color: var(--m-muted); }
html[data-nav-route="market"] .mf-ltv-head b { font: 600 14px var(--m-mono); color: var(--m-text); }
html[data-nav-route="market"] .mf-ltv-range { width: 100%; accent-color: var(--m-accent); }
html[data-nav-route="market"] .mf-ltv-scale { display: flex; justify-content: space-between; font: 500 12px var(--m-sans); color: var(--m-subtle); }
/* Lend side: summary card like "Your supply (projected)". */
html[data-nav-route="market"] .mf-summary { background: var(--m-sunken); border: 1px solid var(--m-border); border-radius: 14px; padding: 18px; margin: 0 0 18px; text-align: center; }
html[data-nav-route="market"] .mf-sum-k { font: 600 14px var(--m-sans); color: var(--m-text); text-align: left; }
html[data-nav-route="market"] .mf-sum-apy { font: 600 40px/1.1 var(--m-mono); color: var(--m-pos); margin-top: 10px; font-variant-numeric: tabular-nums; }
html[data-nav-route="market"] .mf-sum-sub { font: 500 13px var(--m-sans); color: var(--m-subtle); margin-top: 4px; }
html[data-nav-route="market"] .mf-summary dl { margin: 14px 0 0; text-align: left; display: grid; gap: 0; }
html[data-nav-route="market"] .mf-summary dl > div { display: flex; justify-content: space-between; gap: 12px; padding: 10px 0; border-top: 1px solid var(--m-border); font: 500 14px var(--m-sans); color: var(--m-muted); }
html[data-nav-route="market"] .mf-summary dd { margin: 0; font: 600 14px var(--m-mono); color: var(--m-text); }
/* Target LTV slider: track and thumb in the page's own colours, not the browser default. */
html[data-nav-route="market"] .mf-ltv-range { -webkit-appearance: none; appearance: none; height: 6px; border-radius: 999px; background: var(--m-sunken); border: 1px solid var(--m-border); outline: none; margin: 8px 0; cursor: pointer; }
html[data-nav-route="market"] .mf-ltv-range::-webkit-slider-runnable-track { height: 6px; border-radius: 999px; background: var(--m-sunken); }
html[data-nav-route="market"] .mf-ltv-range::-webkit-slider-thumb { -webkit-appearance: none; appearance: none; width: 18px; height: 18px; margin-top: -7px; border-radius: 50%; background: var(--m-accent); border: 3px solid var(--m-raised); box-shadow: var(--m-shadow); cursor: pointer; }
html[data-nav-route="market"] .mf-ltv-range::-moz-range-track { height: 6px; border-radius: 999px; background: var(--m-sunken); }
html[data-nav-route="market"] .mf-ltv-range::-moz-range-thumb { width: 14px; height: 14px; border-radius: 50%; background: var(--m-accent); border: 3px solid var(--m-raised); cursor: pointer; }
html[data-nav-route="market"] .mf-ltv-range:focus-visible { outline: 2px solid var(--m-accent); outline-offset: 4px; border-radius: 999px; }
/* Slider: no box around the range input; only the track and thumb show. */
html[data-nav-route="market"] .mf-ltv-range { height: 20px; background: transparent; border: 0; margin: 4px 0; }
html[data-nav-route="market"] .mf-ltv-range::-webkit-slider-runnable-track { height: 6px; }
html[data-nav-route="market"] .mf-ltv-range::-webkit-slider-thumb { margin-top: -6px; }
/* Slider box rules need !important: the older form styles set the input's own box. */
html[data-nav-route="market"] body.app-mode:not(.stock-detail-mode) #appView .mf-ltv-range,
html[data-nav-route="market"] .mf-ltv-range { height: 20px !important; background: transparent !important; border: 0 !important; box-shadow: none !important; padding: 0 !important; }
/* Repay view: link button to the withdraw page. */
html[data-nav-route="market"] .mf-withdraw-link { display: flex; align-items: center; justify-content: center; width: 100%; height: 44px; margin-top: 12px; border-radius: 999px; border: 1px solid var(--m-border-strong); background: transparent; color: var(--m-text); font: 600 14px var(--m-sans); cursor: pointer; }
html[data-nav-route="market"] .mf-withdraw-link:hover { background: var(--m-sunken); }

/* Phones: leave room at the end of the page so the last lines clear the sticky action bar. */
@media (max-width: 760px) {
  html[data-nav-route="market"] body.app-mode:not(.stock-detail-mode) #appView { padding-bottom: 96px !important; }
  html[data-nav-route="market"] body.app-mode .mobile-action-link { z-index: 20; }
}
/* Market form: a tighter, smaller size on desktop and phone. */
html[data-production-route="market"] body.stock-detail-mode #form { font-size: 14px !important; }
html[data-production-route="market"] body.stock-detail-mode #form .field { margin-bottom: 12px !important; }
html[data-production-route="market"] body.stock-detail-mode #form .balance-row { font-size: 13px !important; margin-bottom: 6px !important; }
html[data-production-route="market"] body.stock-detail-mode #form .amount { height: 48px !important; min-height: 48px !important; border-radius: 10px !important; padding: 0 6px 0 12px !important; }
html[data-production-route="market"] body.stock-detail-mode #form .amount input { font-size: 18px !important; height: 44px !important; min-height: 44px !important; }
html[data-production-route="market"] body.stock-detail-mode #form .max-btn { height: 34px !important; padding: 0 12px !important; font-size: 13px !important; }
html[data-production-route="market"] body.stock-detail-mode #form .hint, html[data-production-route="market"] body.stock-detail-mode #form .notice { font-size: 12px !important; }
html[data-production-route="market"] body.stock-detail-mode #form button.primary { height: 44px !important; min-height: 44px !important; font-size: 14px !important; padding: 0 16px !important; }
html[data-production-route="market"] body.stock-detail-mode .mf-inner { padding: 3px !important; margin-bottom: 14px !important; }
html[data-production-route="market"] body.stock-detail-mode .mf-inner button { height: 32px !important; font-size: 13px !important; }
html[data-production-route="market"] body.stock-detail-mode .tabs button { height: 34px !important; font-size: 13px !important; padding: 6px 12px !important; }
html[data-production-route="market"] body.stock-detail-mode .mf-ltv { margin: 10px 0 !important; }
html[data-production-route="market"] body.stock-detail-mode .mf-ltv-head { font-size: 13px !important; }
/* Borrow form compact: the main button should sit on the first phone screen. Uses the same selector depth as the older detail styles. */
html[data-production-route="market"] body.app-mode.stock-detail-mode #appView #details .amount { height: 44px !important; min-height: 44px !important; padding: 0 4px 0 12px !important; border-radius: 10px !important; }
html[data-production-route="market"] body.app-mode.stock-detail-mode #appView #details .amount input { font-size: 17px !important; height: 40px !important; min-height: 0 !important; }
html[data-production-route="market"] body.app-mode.stock-detail-mode #appView #details .max-btn { height: 30px !important; padding: 0 10px !important; font-size: 12px !important; }
html[data-production-route="market"] body.app-mode.stock-detail-mode #appView #details .field { margin-bottom: 10px !important; }
html[data-production-route="market"] body.app-mode.stock-detail-mode #appView #details .balance-row { font-size: 12px !important; margin-bottom: 4px !important; }
html[data-production-route="market"] body.app-mode.stock-detail-mode #appView #details .hint { font-size: 12px !important; margin-top: 4px !important; }
html[data-production-route="market"] body.app-mode.stock-detail-mode #appView #details button.primary { height: 44px !important; min-height: 44px !important; font-size: 14px !important; }
html[data-production-route="market"] body.app-mode.stock-detail-mode #appView #details .mf-ltv { margin: 6px 0 !important; }
html[data-production-route="market"] body.app-mode.stock-detail-mode #appView #details .mf-ltv-range { height: 16px !important; }
/* Phone: the borrow button sits on the first screen. Tighter top, tabs and limit box. */
@media (max-width: 760px) {
  html[data-production-route="market"] body.app-mode.stock-detail-mode #appView .crumb, html[data-production-route="market"] body.app-mode.stock-detail-mode #appView .mf-crumb { margin: 0 0 8px !important; }
  html[data-production-route="market"] body.app-mode.stock-detail-mode #appView #details { padding-top: 8px !important; }
  html[data-production-route="market"] body.app-mode.stock-detail-mode #appView #form, html[data-production-route="market"] body.app-mode.stock-detail-mode #appView #details .card { padding-top: 10px !important; }
  html[data-production-route="market"] body.app-mode.stock-detail-mode #appView .mf-inner { margin-bottom: 10px !important; }
  html[data-production-route="market"] body.app-mode.stock-detail-mode #appView .tabs { margin-bottom: 8px !important; }
  html[data-production-route="market"] body.app-mode.stock-detail-mode #appView .mf-limit { padding: 10px 12px !important; margin: 4px 0 !important; }
  html[data-production-route="market"] body.app-mode.stock-detail-mode #appView .mf-limit b, html[data-production-route="market"] body.app-mode.stock-detail-mode #appView .mf-limit strong, html[data-production-route="market"] body.app-mode.stock-detail-mode #appView .mf-limit .value { font-size: 22px !important; line-height: 1.1 !important; }
  html[data-production-route="market"] body.app-mode.stock-detail-mode #appView .mf-limit span, html[data-production-route="market"] body.app-mode.stock-detail-mode #appView .mf-limit small, html[data-production-route="market"] body.app-mode.stock-detail-mode #appView .mf-limit p { font-size: 12px !important; }
  html[data-production-route="market"] body.app-mode.stock-detail-mode #appView button.primary { margin-top: 6px !important; }
}
/* Phone: fit the borrow button on the first screen. */
@media (max-width: 760px) {
  html[data-production-route="market"] body.app-mode.stock-detail-mode #appView .tabs { padding: 3px !important; height: auto !important; }
  html[data-production-route="market"] body.app-mode.stock-detail-mode #appView .tabs button { height: 32px !important; min-height: 32px !important; padding: 0 10px !important; }
  html[data-production-route="market"] body.app-mode.stock-detail-mode #appView .mf-inner { padding: 3px !important; margin-bottom: 8px !important; }
  html[data-production-route="market"] body.app-mode.stock-detail-mode #appView .mf-inner button { height: 30px !important; min-height: 30px !important; }
  html[data-production-route="market"] body.app-mode.stock-detail-mode #appView .mf-ltv-range { height: 16px !important; padding: 0 !important; margin: 2px 0 !important; }
  html[data-production-route="market"] body.app-mode.stock-detail-mode #appView .mf-ltv-scale { display: none !important; }
  html[data-production-route="market"] body.app-mode.stock-detail-mode #appView .mf-ltv { gap: 4px !important; }
  html[data-production-route="market"] body.app-mode.stock-detail-mode #appView .mf-limit { padding: 8px 10px !important; }
  html[data-production-route="market"] body.app-mode.stock-detail-mode #appView .mf-limit b, html[data-production-route="market"] body.app-mode.stock-detail-mode #appView .mf-limit strong { font-size: 20px !important; }
}
/* Phone: hide the repeated breadcrumb and make the slider a thin line so the Borrow button fits on the first screen. */
@media (max-width: 760px) {
  html body.app-mode.stock-detail-mode #appView .mf-crumb { display: none !important; }
  html body.app-mode.stock-detail-mode #appView input[type=range].mf-ltv-range { height: 16px !important; min-height: 16px !important; max-height: 16px !important; padding: 0 !important; }
}
/* Borrow form on every width: thin slider, compact limit box and small risk note, so the Connect or Borrow button fits without scrolling on a laptop. */
html body.app-mode.stock-detail-mode #appView input[type=range].mf-ltv-range { height: 16px !important; min-height: 16px !important; max-height: 16px !important; padding: 0 !important; }
html body.app-mode.stock-detail-mode #appView .mf-limit { padding: 10px 14px !important; }
html body.app-mode.stock-detail-mode #appView .mf-limit b, html body.app-mode.stock-detail-mode #appView .mf-limit strong { font-size: 22px !important; }
html body.app-mode.stock-detail-mode #appView .mf-fine { font-size: 11px !important; line-height: 1.4 !important; margin-top: 8px !important; }
/* The main button stays on screen while the borrow form is in view, so it never needs a scroll to reach. */
html body.app-mode.stock-detail-mode #appView #form button.primary { position: sticky !important; bottom: 12px !important; z-index: 6 !important; box-shadow: 0 10px 24px -8px rgba(0,0,0,.45) !important; }
/* Desktop and laptop: the Borrow button must show without scrolling. Hide the repeated breadcrumb and the slider scale; put the limit on one line. */
html body.app-mode.stock-detail-mode #appView .mf-crumb { display: none !important; }
html body.app-mode.stock-detail-mode #appView .mf-ltv-scale { display: none !important; }
html body.app-mode.stock-detail-mode #appView .mf-limit { display: flex !important; align-items: center !important; justify-content: space-between !important; flex-wrap: wrap !important; gap: 2px 12px !important; padding: 10px 14px !important; }
html body.app-mode.stock-detail-mode #appView .mf-limit b, html body.app-mode.stock-detail-mode #appView .mf-limit strong { font-size: 22px !important; }
html body.app-mode.stock-detail-mode #appView .mf-limit span, html body.app-mode.stock-detail-mode #appView .mf-limit p, html body.app-mode.stock-detail-mode #appView .mf-limit small { font-size: 12px !important; }
/* Repay and borrow forms: tighter boxes, less space between rows, and no heavy shadow on the disabled button. */
html body.app-mode.stock-detail-mode #appView #form .position-metrics { padding: 10px 14px !important; margin: 8px 0 !important; }
html body.app-mode.stock-detail-mode #appView #form .position-metrics > div { padding: 6px 0 !important; font-size: 13px !important; }
html body.app-mode.stock-detail-mode #appView #form .full-repay { margin: 4px 0 !important; min-height: 0 !important; height: 36px !important; font-size: 13px !important; }
html body.app-mode.stock-detail-mode #appView #form button.primary, html body.app-mode.stock-detail-mode #appView #form button.primary:disabled { box-shadow: none !important; margin-top: 6px !important; }
html body.app-mode.stock-detail-mode #appView #form .notice { font-size: 12px !important; line-height: 1.45 !important; margin: 6px 0 0 !important; }
/* Position card below the form: tighter rows. */
html body.app-mode.stock-detail-mode #appView .attribute { padding: 8px 0 !important; }
html body.app-mode.stock-detail-mode #appView .attribute span, html body.app-mode.stock-detail-mode #appView .attribute b { font-size: 13px !important; }
html body.app-mode.stock-detail-mode #appView .position-summary { padding: 12px 14px !important; }
html body.app-mode.stock-detail-mode #appView .position-summary > div { padding: 6px 0 !important; }
/* Repay view: hidden extra box, and the withdraw link at the bottom. */
html body.app-mode.stock-detail-mode #appView #form .mf-hide { display: none !important; }
html body.app-mode.stock-detail-mode #appView #form .mf-withdraw-link { display: flex; align-items: center; justify-content: center; width: 100%; height: 44px; margin: 12px 0 0; border-radius: 999px; border: 1px solid var(--m-border-strong); background: transparent; color: var(--m-text); font: 600 14px var(--m-sans); cursor: pointer; }
html body.app-mode.stock-detail-mode #appView #form .mf-withdraw-link:hover { background: var(--m-sunken); }
/* Repay view: stock collateral withdraw field, laid out like the Borrow fields above it. */
html body.app-mode.stock-detail-mode #appView #form .mf-wd-go { display: flex !important; align-items: center !important; justify-content: center !important; width: 100% !important; height: 52px !important; font-size: 15px !important; margin: 8px 0 0 !important; border-radius: 999px !important; border: 1px solid var(--m-border-strong) !important; background: transparent !important; color: var(--m-text) !important; font: 600 15px var(--m-sans) !important; cursor: pointer !important; }
/* Markets page: the filter chips (All / High liquidity / Lowest rate) as one segmented control on their own row. */
html[data-nav-route="market"] #stockListPanel .toolbar { flex-wrap: wrap !important; row-gap: 10px; }
/* Markets filters: the chips (All / High liquidity / Lowest rate) are the only ordering control. */
html[data-nav-route="market"] #stockListPanel .market-filterbar label[for="marketLiquidityFilter"],
html[data-nav-route="market"] #stockListPanel #marketSort { display: none !important; }
/* Search box: no blue focus line. */
html[data-nav-route="market"] #stockListPanel .search-wrap:focus-within,
html[data-nav-route="market"] #stockListPanel .search-wrap input:focus,
html[data-nav-route="market"] #stockListPanel .search-wrap input:focus-visible { outline: none !important; box-shadow: none !important; border-color: var(--m-border-strong) !important; }
/* Toolbar: search shrinks to fit, so the sort and Refresh controls stay inside the panel. */
html[data-nav-route="market"] #stockListPanel .toolbar .search-wrap { flex: 1 1 0 !important; min-width: 0 !important; width: auto !important; }
html[data-nav-route="market"] #stockListPanel .toolbar select#marketSort { min-width: 170px !important; width: 170px !important; }
/* Available USDC filter: one row, label and select side by side, aligned to the left like the other controls. */
html[data-nav-route="market"] #stockListPanel .market-filterbar { display: flex !important; flex-direction: row !important; align-items: center !important; justify-content: flex-start !important; gap: 10px !important; width: 100% !important; height: auto !important; padding: 4px 0 !important; color: var(--m-muted) !important; font: 500 13px var(--m-sans) !important; }
html[data-nav-route="market"] #stockListPanel .market-filterbar label { display: flex !important; flex-direction: row !important; align-items: center !important; gap: 10px !important; }
html[data-nav-route="market"] #stockListPanel .market-filterbar select { height: 36px; min-width: 140px; border-radius: 10px; border: 1px solid var(--m-border-strong); background: var(--m-raised); color: var(--m-text); padding: 0 10px; font: 500 13px var(--m-sans); }
html[data-nav-route="market"] .lend-borrow-filters { flex: 1 1 100%; width: 100%; order: 10; display: flex; align-items: center; gap: 4px; padding: 4px; margin-top: 10px; box-sizing: border-box; background: var(--m-sunken); border: 1px solid var(--m-border); border-radius: 999px; overflow-x: auto; scrollbar-width: none; }
html[data-nav-route="market"] .lend-borrow-filters::-webkit-scrollbar { display: none; }
html[data-nav-route="market"] .lend-borrow-filters button { flex: 1 1 0; min-width: max-content; height: 34px; padding: 0 14px; border: 0; border-radius: 999px; background: transparent; color: var(--m-muted); font: 600 13px var(--m-sans); white-space: nowrap; cursor: pointer; }
html[data-nav-route="market"] .lend-borrow-filters button:hover { color: var(--m-text); }
html[data-nav-route="market"] .lend-borrow-filters button[aria-pressed="true"] { background: var(--m-raised); color: var(--m-text); box-shadow: var(--m-shadow); }
/* Lend-side Withdraw: the divider lines above the remaining position row are removed. */
html body.app-mode.stock-detail-mode #appView #form .position-metrics.mf-flat { border-top: 0 !important; }
html body.app-mode.stock-detail-mode #appView #form .position-metrics.mf-flat > div { border-top: 0 !important; }
/* Repay view: the main button and the withdraw button are the same size. */
html body.app-mode.stock-detail-mode #appView #form > button#action.primary { height: 52px !important; min-height: 52px !important; font-size: 15px !important; }
html body.app-mode.stock-detail-mode #appView #form .mf-wd-go:hover { background: var(--m-sunken) !important; }
html body.app-mode.stock-detail-mode #appView #form .mf-wd-note { margin: 6px 0 0 !important; font: 400 12px/1.4 var(--m-sans) !important; color: var(--m-muted) !important; }
/* Withdraw page (lend side): the Stock collateral choice is hidden; Lent USDC is the only option. */
html body.app-mode.stock-detail-mode #appView #form .withdraw-choice-button[data-withdraw-kind="collateral"] { display: none !important; }
/* Withdraw page: only Lent USDC is possible here, so the 'Withdraw asset' label and the single choice card are hidden. */
html body.app-mode.stock-detail-mode #appView #form .withdraw-choice-label, html body.app-mode.stock-detail-mode #appView #form .withdraw-choice { display: none !important; }
