/* THE CRM ON AN IPHONE (CSS and layout only).
 *
 * One stylesheet, loaded last by the CRM page (Vault Money CRM.dc.html) and by login.html. It sits in /pages/
 * because that is the one anonymous wildcard in staticwebapp.config.json that is also open to the Delta Bridge and
 * Vault Payments roles: a file at the web root would answer 403 to a Delta Bridge desk (the root wildcard names the
 * Vault roles only) and the routes cannot grow (the shipped config is pinned at its size ceiling).
 *
 * Nothing here changes what a screen says or does. It changes sizes, spacing, wrapping and what scrolls.
 *
 * EVERYTHING IS INSIDE A WIDTH QUERY. From 1280px up this file draws nothing, so a desk is pixel-identical; the one block that
 * reaches above 1023px is the deals table at 1024-1279px (the last block but one), where the table scrolls inside its own box.
 * The only rules outside a query are the safe-area and dynamic-viewport lines, which are harmless on a desk: an
 * inset is 0 without viewport-fit=cover and a 100vh fallback always precedes the 100dvh line.
 *
 * COLOUR. Almost none is written here. The Delta Bridge workspace re-colours the CRM's inline styles (theme.js) and
 * its own stylesheet, so a hex written here would be Vault's palette showing through on a Delta desk. Where a tone is
 * unavoidable it is currentColor or a neutral alpha of it, which follows whichever theme is on.
 *
 * SCALE. Spacing is 4, 8, 12, 16, 24. Type is 12 / 14 / 16 / 20. A tap target is 44. */

/* ------------------------------------------------------------------------------------------------------------
   Phones, foldables and tablets (<= 1023px): ONE layout, no separate 769-820 band; the desk layout starts at 1024
   ------------------------------------------------------------------------------------------------------------ */
@media (max-width: 1023px) {
  :root {
    --m-gap: 8px;
    --m-pad: 16px;
    --m-tap: 44px;
    --m-top: env(safe-area-inset-top, 0px);
    --m-left: env(safe-area-inset-left, 0px);
    --m-right: env(safe-area-inset-right, 0px);
    --m-bottom: env(safe-area-inset-bottom, 0px);
  }

  html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
  body { min-width: 0; }

  /* ---- Shell ---------------------------------------------------------------------------------------------- */
  /* The page is one column that never outgrows the phone. */
  .vm-main { min-width: 0 !important; max-width: 100vw; padding-top: 0 !important; }
  .vm-viewport { padding: 12px calc(var(--m-pad) + var(--m-right)) 12px calc(var(--m-pad) + var(--m-left)) !important; min-width: 0; }
  .vm-viewport > div { min-width: 0; max-width: 100%; }

  /* ---- Header: a title beside the menu button, then the tools, WRAPPED so every action is in view ------------------ */
  /* The tools used to be one row that swiped sideways, which hid "Month-end pack" and "New deal" on first view. They wrap now, and the
     bar scrolls away with the page (the menu button is fixed, so the way back to the menu never leaves). */
  html body header:not(#vm-m) {
    position: static !important;
    display: flex !important; flex-direction: column !important; align-items: stretch !important; gap: 8px !important;
    padding: calc(var(--m-top) + 8px) calc(var(--m-pad) + var(--m-right)) 8px calc(var(--m-pad) + var(--m-left)) !important;
  }
  html body header:not(#vm-m) .vm-headtitle { min-height: var(--m-tap); display: flex; flex-direction: column; justify-content: center; padding-left: 52px; max-width: 100%; }
  html body header:not(#vm-m) h1 { font-size: 20px !important; line-height: 24px; letter-spacing: -0.2px !important; margin: 0; }
  html body header:not(#vm-m) .vm-subtitle {
    font-size: 12px !important; line-height: 16px; margin-top: 0 !important;
    display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden;
  }
  html body header:not(#vm-m) .vm-headtools {
    display: flex !important; flex-wrap: wrap !important; align-items: center; justify-content: flex-start !important; gap: 8px !important;
    width: 100% !important; margin: 0 !important; overflow: visible; padding-bottom: 2px;
  }
  html body header:not(#vm-m) .vm-headtools > * { flex: 0 0 auto !important; max-width: 100%; }
  html body header:not(#vm-m) .vm-headtools > span { display: flex !important; flex-wrap: wrap !important; width: auto !important; gap: 8px; }
  html body header:not(#vm-m) .vm-headtools > span > button { flex: 0 0 auto !important; }
  html body header:not(#vm-m) .vm-headtools input { width: 180px !important; max-width: 100%; }
  html body header:not(#vm-m) .vm-userbox { order: -1; width: auto !important; margin: 0 !important; padding-left: 0 !important; border-left: 0 !important; flex-wrap: nowrap !important; gap: 8px !important; }
  html body header:not(#vm-m) .vm-headtools button { min-height: var(--m-tap); white-space: nowrap; }

  /* ---- Menu: off-canvas, a button that opens it AND the same button as its close ---------------------------- */
  .vm-burger {
    top: calc(var(--m-top) + 8px) !important; left: calc(var(--m-left) + 8px) !important; width: var(--m-tap) !important; height: var(--m-tap) !important;
    border-radius: 12px !important; font-size: 22px !important; -webkit-tap-highlight-color: transparent;
  }
  .vm-aside {
    /* Pinned to the left edge: closed it is off-canvas by transform alone, open it is translateX(0) at left:0, so the open drawer never carries a
       leftover negative offset. The slide is short, and the close button (below) waits for it, so the two never disagree about where the drawer is. */
    left: 0 !important; box-sizing: border-box; transition: transform .2s ease !important;
    width: min(86vw, 320px) !important; max-width: 100vw;
    padding-top: calc(var(--m-top) + 12px) !important; padding-left: calc(14px + var(--m-left)) !important;
    padding-bottom: calc(16px + var(--m-bottom)) !important; overscroll-behavior: contain;
  }
  /* Open: the button moves onto the drawer's top right, above it, and turns into a cross. It is the close. */
  body.vm-nav-open .vm-burger {
    z-index: 310 !important; left: calc(min(86vw, 320px) - var(--m-tap) - 8px) !important; font-size: 0 !important;
  }
  /* The button jumps to the drawer's corner only once the drawer has arrived (and back after it has left), so it is never past the drawer's edge mid-slide. */
  .vm-burger { box-sizing: border-box; transition-property: left; transition-duration: 0s; transition-delay: .2s; }
  body.vm-nav-open .vm-burger::before { display: none; }
  /* the app bar carries the title beside the button, so the button needs no fade of its own */
  .vm-burger::before { display: none !important; }
  body.vm-nav-open .vm-burger::after { content: "\2715"; font-size: 18px; line-height: 1; }
  body.vm-nav-open .vm-backdrop { z-index: 290; -webkit-tap-highlight-color: transparent; }
  body.vm-nav-open { overflow: hidden; }
  /* the sidebar's logo gives way to the close button */
  .vm-aside .vm-logo { padding-right: 56px !important; }
  .vm-aside nav { overflow-x: hidden; }
  .vm-aside nav button, .vm-aside nav a, .vm-aside > button { min-height: var(--m-tap); }
  .vm-aside nav .vm-navgrp { min-height: 40px; }
  .vm-aside nav a, .vm-aside nav button { box-sizing: border-box; }

  /* ---- Bottom bar --------------------------------------------------------------------------------------------- */
  .vm-bottomnav {
    padding: 4px calc(4px + var(--m-right)) calc(4px + var(--m-bottom)) calc(4px + var(--m-left)) !important;
    min-height: calc(56px + var(--m-bottom));
  }
  .vm-bottomnav button { min-height: 48px; justify-content: center; }
  .vm-main { padding-bottom: calc(72px + var(--m-bottom)) !important; }

  /* ---- Tap targets and iOS zoom -------------------------------------------------------------------------------- */
  html body input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="file"]):not([type="color"]),
  html body select, html body textarea { font-size: 16px !important; min-height: 44px; box-sizing: border-box; max-width: 100%; }
  html body textarea { min-height: 88px; }
  html body input[type="checkbox"], html body input[type="radio"] { width: 20px; height: 20px; flex: 0 0 auto; }
  /* a row whose job is a checkbox is a 44px target, not the 20px box */
  html body label:has(> input[type="checkbox"]), html body label:has(> input[type="radio"]) { min-height: var(--m-tap); display: inline-flex; align-items: center; gap: 8px; }
  html body .vm-main button, html body .vm-cdrawer button, html body [role="dialog"] button, html body .vm-bottomnav button { min-height: var(--m-tap); }
  /* an icon-only square (a fixed 10 to 39px width in its style) is a 44px square; a labelled button is already wider than that */
  html body .vm-main button[style*="width: 1"], html body .vm-main button[style*="width: 2"], html body .vm-main button[style*="width: 3"],
  html body .vm-cdrawer button[style*="width: 1"], html body .vm-cdrawer button[style*="width: 2"], html body .vm-cdrawer button[style*="width: 3"] { min-width: var(--m-tap); }
  /* tabs and chip rows */
  html body [role="tab"] { min-height: var(--m-tap); display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto; white-space: nowrap; }

  /* A tab bar scrolls inside its own strip. It does not wrap into four rows of chips, and it does not widen the page. */
  html body .vm-main [role="tablist"]:not(#vm-m) {
    display: flex !important; flex-wrap: nowrap !important; overflow-x: auto; overflow-y: hidden; -webkit-overflow-scrolling: touch;
    scrollbar-width: none; scroll-snap-type: x proximity; scroll-padding-left: var(--m-pad); gap: 8px !important;
    margin-left: calc(-1 * var(--m-pad)) !important; margin-right: calc(-1 * var(--m-pad)) !important;
    padding: 2px var(--m-pad) 6px !important; max-width: 100vw;
  }
  html body .vm-main [role="tablist"]::-webkit-scrollbar { display: none; }
  html body .vm-main [role="tablist"] > * { scroll-snap-align: start; flex: 0 0 auto; }

  /* a strip that scrolls ends in a fade, never a cut (the same mask the file's other sideways scrollers wear) */
  html body .vm-main [role="tablist"]:not(#vm-m) {
    -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 26px), transparent); mask-image: linear-gradient(to right, #000 calc(100% - 26px), transparent);
  }

  /* ---- Tables: their own scroller; the first column stays put ---------------------------------------------------- */
  html body .vm-main table { display: block !important; max-width: 100% !important; overflow-x: auto; -webkit-overflow-scrolling: touch; overscroll-behavior-x: contain; }
  html body .vm-main table th:first-child, html body .vm-main table td:first-child {
    position: sticky; left: 0; z-index: 1; background: inherit; box-shadow: 1px 0 0 rgba(128, 128, 128, .22);
  }
  html body .vm-main table th, html body .vm-main table td { padding-top: 10px; padding-bottom: 10px; }
  /* A grid item will not shrink below its content (min-width:auto), so a table that scrolls inside a card still made the card, and with
     it the whole page, as wide as the table's rows (P&L > Owed to us, 936px on a 720px screen). Items may shrink; the scroller moves. */
  html body .vm-main [style*="display: grid"] > *, html body .vm-main [style*="display:grid"] > * { min-width: 0; }
  /* A table is its own scroller here, so a min-width written for the desk (760px, 720px) must not make the BOX wider than its card:
     the rows inside keep their width (cells do not wrap) and it is the scroller that moves. */
  html body .vm-main table { min-width: 0 !important; }
  /* A sticky head pins to its scroller, and this scroller never scrolls downward, so the desk's top:74px (the page header's height)
     parked the head 74px INTO the rows: "Month" printed over "YTD" in Month by month. The head stays in its own place; only the first
     column is pinned (sideways). Heads built from a grid of divs are not pinned either: the app bar scrolls away on a phone. */
  html body .vm-main thead th, html body .vm-main .vm-sticky-head { top: auto !important; }
  html body .vm-main thead th:not(:first-child), html body .vm-main .vm-sticky-head { position: static !important; }

  /* ---- Drawers and modals: the whole screen, with a close you can hit --------------------------------------------- */
  html body .vm-cdrawer {
    width: 100vw !important; max-width: 100vw !important; left: 0 !important; right: 0 !important;
    height: 100vh; height: 100dvh; border-left: 0 !important;
  }
  html body .vm-cdrawer > div { padding-top: var(--m-top); }
  html body .vm-cdrawer [style*="padding: 22px 24px"], html body .vm-cdrawer [style*="padding:22px 24px"] { padding: 16px var(--m-pad) !important; }
  html body .vm-drawerscroll { padding: 16px calc(var(--m-pad) + var(--m-right)) calc(96px + var(--m-bottom)) calc(var(--m-pad) + var(--m-left)) !important; }
  html body .vm-cdrawer button[aria-label="Close"], html body [role="dialog"] button[aria-label="Close"], html body button[aria-label="Close"] {
    min-width: var(--m-tap); min-height: var(--m-tap); display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto;
  }
  /* The drawer's head: the close is pinned to its top right corner and the head reserves room for it, so a long name or a row of chips
     wraps under the title instead of squeezing it to a column of one word per line. */
  html body .vm-cdrawer > div > div:first-child { position: relative; padding-right: 64px !important; }
  html body .vm-cdrawer > div > div:first-child[style*="display: flex"], html body .vm-cdrawer > div > div:first-child > div[style*="display: flex"] { flex-wrap: wrap; row-gap: 8px; }
  html body .vm-cdrawer > div > div:first-child > div[style*="flex: 1 1 0%"], html body .vm-cdrawer > div > div:first-child > div > div[style*="flex: 1 1 0%"] { flex: 1 1 160px !important; }
  html body .vm-cdrawer button[aria-label="Close"] { position: absolute; top: 8px; right: 8px; z-index: 2; }
  html body .vm-drawerscroll [style*="display: flex"]:not([style*="flex-direction: column"]) { flex-wrap: wrap; row-gap: 8px; }
  /* The client drawer's logo carries a small round x (Remove logo) pinned to its corner. On a phone it grew to a 44px tap target and sat over the
     logo beside the drawer's real close, so the drawer had two crosses. One close control: the logo can still be removed on a desk. */
  html body .vm-cdrawer button[title="Remove logo"] { display: none !important; }
  /* The client drawer's action row (Edit / Pack / Statement) scrolls rather than squeezing three buttons into one line. */
  html body .vm-cdrawer [style*="margin-top: 14px"][style*="display: flex"] { flex-wrap: wrap; }

  /* A full-screen overlay (the client 360 view, the pack builders): its content clears the menu button and the bottom bar, and the
     row of buttons across its top wraps instead of squeezing a label to three lines. */
  html body [style*="position: fixed"][style*="inset: 0"] div[style*="max-width: 1100px"] {
    padding: calc(var(--m-top) + 64px) calc(var(--m-pad) + var(--m-right)) calc(96px + var(--m-bottom)) calc(var(--m-pad) + var(--m-left)) !important;
  }
  html body [style*="position: fixed"][style*="inset: 0"] div[style*="max-width: 1100px"] > div[style*="display: flex"][style*="margin-bottom: 16px"] { flex-wrap: wrap; row-gap: 8px; }
  html body [style*="position: fixed"][style*="inset: 0"] button { white-space: nowrap; }
  /* a scrim that is nearly, not fully, opaque lets the page's own headings ghost through behind a full-screen view: blur them */
  html body [style*="position: fixed"][style*="inset: 0"] { -webkit-backdrop-filter: blur(18px); backdrop-filter: blur(18px); }

  /* Tables inside a full-screen view sit outside .vm-main, so the table rule above never reached them */
  html body [style*="position: fixed"][style*="inset: 0"] table { display: block !important; max-width: 100% !important; min-width: 0 !important; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  html body [style*="position: fixed"][style*="inset: 0"] table th, html body [style*="position: fixed"][style*="inset: 0"] table td { white-space: nowrap; }

  /* Modals: a dialog card is full-bleed on a phone, its content scrolls, its close is reachable. */
  html body [style*="position: fixed"][style*="inset: 0"] > div[style*="border-radius"],
  html body [style*="position:fixed"][style*="inset:0"] > div[style*="border-radius"] {
    width: 100% !important; max-width: 100vw !important; min-width: 0 !important; max-height: 100vh; max-height: 100dvh; height: auto;
    border-radius: 0 !important; overflow-y: auto; -webkit-overflow-scrolling: touch;
    padding-bottom: calc(16px + var(--m-bottom)) !important;
  }
}

/* ------------------------------------------------------------------------------------------------------------
   Lists as cards (<= 1023px). ONE pattern for every list the desk reads row by row: a row is a small card, never a table
   squeezed beside a menu and never one that swipes sideways. Transactions (the deal rows), Clients, Cards > Applications and
   Cards > Sign-up links all follow it. The full table comes back at 1024px, where it fits beside the 238px menu.
   Labels are the column's own heading (Volume, Received, Revenue, Net, Margin ...), not new wording.
   ------------------------------------------------------------------------------------------------------------ */
@media (max-width: 1023px) {
  /* every figure and chip stays on one line; whatever must give, gives by wrapping to the next line of the card */
  html body .vm-blotter-row .num, html body .vm-main table.vm-stack td .num { white-space: nowrap; }

  /* ---- Transactions: the deal rows --------------------------------------------------------------------------------- */
  html body .vm-main .vm-blotter.vm-sticky-head[style*="grid-template-columns"] { display: none !important; }
  html body .vm-main .vm-blotter-row > div:first-child > div > div:first-child { white-space: normal; overflow: visible; text-overflow: clip; overflow-wrap: anywhere; }
  html body .vm-main .vm-blotter-row > div:first-child > div > div:nth-child(2) { flex-wrap: wrap; row-gap: 4px; }
  html body .vm-main .vm-blotter-row > div:first-child > div > div:nth-child(2) > * { white-space: nowrap; }
}

@media (min-width: 641px) and (max-width: 1023px) {
  html body .vm-main .vm-blotter-row {
    grid-template-columns: repeat(4, minmax(min-content, 1fr)) !important; gap: 10px 16px !important; padding: 14px 16px !important; align-items: start !important;
  }
  html body .vm-main .vm-blotter-row > div { min-width: 0; white-space: nowrap !important; text-align: left !important; }
  html body .vm-main .vm-blotter-row > div:first-child { grid-column: 1 / -1; white-space: normal !important; }
  /* the four figures: volume, received, revenue, net, each under its own heading */
  html body .vm-main .vm-blotter-row > div:nth-child(n+2):nth-child(-n+5)::before {
    display: block; margin-bottom: 2px; font-size: 12px; line-height: 16px; font-weight: 600; color: currentColor; opacity: .62;
  }
  html body .vm-main .vm-blotter-row > div:nth-child(2)::before { content: "Volume"; }
  html body .vm-main .vm-blotter-row > div:nth-child(3)::before { content: "Received"; }
  html body .vm-main .vm-blotter-row > div:nth-child(4)::before { content: "Revenue"; }
  html body .vm-main .vm-blotter-row > div:nth-child(5)::before { content: "Net"; }
  html body .vm-main .vm-blotter-row > div:nth-child(6) { grid-column: 1 / span 3; justify-content: flex-start !important; }
  html body .vm-main .vm-blotter-row > div:nth-child(7) { grid-column: 4; justify-self: end; text-align: right !important; }
  html body .vm-main .vm-blotter-row > div:nth-child(7) > span { white-space: nowrap; }
}

/* The Transactions KPI tiles show the FULL figure from 641px (the short one is phone-only) at 25px; in a 150px-minimum auto-fit
   grid a nine-figure volume spills over its neighbour on a wider face. A 300px minimum gives each tile room for it. */
@media (min-width: 641px) and (max-width: 1023px) {
  html body .vm-main div[style*="auto-fit"][style*="minmax(150px"] { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)) !important; }
  html body .vm-main div[style*="auto-fit"][style*="minmax(150px"] > * { min-width: 0; }
}

@media (max-width: 1023px) {
  /* ---- Tables that become cards: Clients, Cards > Applications, Cards > Sign-up links -------------------------------- */
  html body .vm-main table.vm-stack, html body .vm-main table[data-table="applications"], html body .vm-main table[data-table="links"] {
    display: block !important; width: 100% !important; min-width: 0 !important; max-width: 100% !important; overflow: visible !important;
  }
  html body .vm-main table.vm-stack > thead, html body .vm-main table[data-table="applications"] > thead, html body .vm-main table[data-table="links"] > thead { display: none !important; }
  html body .vm-main table.vm-stack > tbody, html body .vm-main table[data-table="applications"] > tbody, html body .vm-main table[data-table="links"] > tbody { display: block !important; }
  html body .vm-main table.vm-stack tr, html body .vm-main table[data-table="applications"] tr, html body .vm-main table[data-table="links"] tr {
    display: flex !important; flex-wrap: wrap; align-items: center; gap: 6px 16px; padding: 14px 16px !important; box-sizing: border-box;
    border-top: 1px solid rgba(128, 128, 128, .22);
  }
  html body .vm-main table.vm-stack td, html body .vm-main table[data-table="applications"] td, html body .vm-main table[data-table="links"] td {
    display: block !important; position: static !important; box-shadow: none !important; background: transparent !important; border: 0 !important;
    padding: 0 !important; min-width: 0; max-width: 100% !important; white-space: normal !important; text-align: left !important; overflow: visible !important; text-overflow: clip !important;
  }
  /* a small heading above a figure that has one */
  html body .vm-main table.vm-stack td[data-k]::before { content: attr(data-k); display: block; margin-bottom: 2px; font-size: 12px; line-height: 16px; font-weight: 600; opacity: .62; }

  /* Clients: the name, the industry, four figures in a row, then the status */
  html body .vm-main table.vm-stack-clients td:first-child { flex: 1 1 100%; }
  html body .vm-main table.vm-stack-clients td:nth-child(2) { flex: 1 1 100%; font-size: 13px; }
  html body .vm-main table.vm-stack-clients td:nth-child(n+3):nth-child(-n+6) { flex: 1 1 20%; }
  html body .vm-main table.vm-stack-clients td:nth-child(n+3):nth-child(-n+6)::before { display: block; margin-bottom: 2px; font-size: 12px; line-height: 16px; font-weight: 600; opacity: .62; }
  html body .vm-main table.vm-stack-clients td:nth-child(3)::before { content: "Margin"; }
  html body .vm-main table.vm-stack-clients td:nth-child(4)::before { content: "Volume YTD"; }
  html body .vm-main table.vm-stack-clients td:nth-child(5)::before { content: "Profit YTD"; }
  html body .vm-main table.vm-stack-clients td:nth-child(6)::before { content: "Trades"; }
  html body .vm-main table.vm-stack-clients td:nth-child(n+7) { flex: 1 1 auto; }
  html body .vm-main table.vm-stack-clients td:last-child { flex: 1 1 100%; }

  /* Applications: applicant and status on the first line, then reference, client, type, BIN, issuer, updated */
  html body .vm-main table[data-table="applications"] td { order: 5; font-size: 13px; }
  html body .vm-main table[data-table="applications"] td:nth-child(2) { order: 1; flex: 1 1 0; min-width: 140px; font-size: 15px; font-weight: 600; }
  html body .vm-main table[data-table="applications"] td:nth-child(6) { order: 2; flex: 0 0 auto; margin-left: auto; }
  html body .vm-main table[data-table="applications"] td:nth-child(1) { order: 3; flex: 0 0 auto; opacity: .75; }
  html body .vm-main table[data-table="applications"] td:nth-child(3) { order: 4; flex: 1 1 auto; }
  html body .vm-main table[data-table="applications"] td:nth-child(5)::before { content: "BIN "; opacity: .62; }
  html body .vm-main table[data-table="applications"] td[data-auto-cell] { order: 7; flex: 1 1 100%; }
  html body .vm-main table[data-table="applications"] td:last-child { order: 8; flex: 1 1 100%; opacity: .75; }

  /* Sign-up links: the name, the short code with its full-width link and Copy / Remove side by side, then the facts */
  html body .vm-main table[data-table="links"] td { order: 4; font-size: 13px; flex: 0 1 auto; }
  html body .vm-main table[data-table="links"] td:first-child { order: 1; flex: 1 1 100%; font-size: 15px; font-weight: 600; }
  html body .vm-main table[data-table="links"] td:has([data-short-code]), html body .vm-main table[data-table="links"] td:has(> button[data-act="set-short-code"]) { order: 2; flex: 1 1 100%; }
  html body .vm-main table[data-table="links"] [data-short-code] { min-width: 0 !important; width: 100%; }
  html body .vm-main table[data-table="links"] [data-short-code] input { width: 100% !important; box-sizing: border-box; }
  html body .vm-main table[data-table="links"] [data-short-code] > div:last-child { display: grid !important; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px !important; }
  html body .vm-main table[data-table="links"] [data-short-code] > div:last-child > button { width: 100%; white-space: nowrap; }
  html body .vm-main table[data-table="links"] td:last-child { order: 9; flex: 1 1 100%; }
}

/* ------------------------------------------------------------------------------------------------------------
   Tighter phones (<= 430px: every current iPhone in portrait)
   ------------------------------------------------------------------------------------------------------------ */
@media (max-width: 430px) {
  :root { --m-pad: 12px; }
  html body header:not(#vm-m) h1 { font-size: 18px !important; line-height: 22px; }
}

@media (max-width: 390px) {
  html body header:not(#vm-m) .vm-headtools input { width: 148px !important; }
}

@media (max-width: 375px) {
  :root { --m-pad: 12px; }
  .vm-aside { width: min(88vw, 300px) !important; }
  body.vm-nav-open .vm-burger { left: calc(min(88vw, 300px) - var(--m-tap) - 8px) !important; }
}

/* ------------------------------------------------------------------------------------------------------------
   Deals table at 1024-1279px. The desk layout (menu expanded, seven-column table) stays from 1024px; at these widths the table
   no longer fits beside the 238px menu, so it scrolls INSIDE its own box (the page does not), the client column stays put, and
   the ref, amounts, chips and AML badge never wrap. 1280px and up is not touched by this block.
   ------------------------------------------------------------------------------------------------------------ */
@media (min-width: 1024px) and (max-width: 1279px) {
  /* The card that holds the filter bar, the heading row and the date groups is the one scroller. Its filter bar stays put (sticky, one card wide). */
  html body .vm-main div:has(> .vm-blotter.vm-sticky-head) { overflow-x: auto !important; overflow-y: hidden !important; max-width: 100%; overscroll-behavior-x: contain; }
  html body .vm-main div:has(> .vm-blotter.vm-sticky-head) > div { background-color: inherit; }
  html body .vm-main div:has(> .vm-blotter.vm-sticky-head) > :first-child { position: sticky; left: 0; z-index: 3; box-sizing: border-box; }
  html body .vm-main div:has(> .vm-blotter.vm-sticky-head) > :not(:first-child) { min-width: 1120px; box-sizing: border-box; }
  html body .vm-main .vm-blotter-row { background-color: inherit; }
  html body .vm-main .vm-blotter-row > div:nth-child(n+2), html body .vm-main .vm-blotter-row > div:first-child > div > div:nth-child(2) > * { white-space: nowrap; }
  /* the client column stays in view while the figures scroll under it */
  html body .vm-main .vm-blotter-row > div:first-child, html body .vm-main .vm-blotter.vm-sticky-head > div:first-child {
    position: sticky; left: 0; z-index: 2; background-color: inherit; box-sizing: border-box;
  }
  /* On the dark theme the card is translucent (the glow shows through), so the pinned cell needs a solid fill of its own or the figures
     would show through it as they scroll under. It is the card's tone laid over the page: one of the few colours written in this file,
     and the light theme needs none (its card is already solid, and inherits). */
  html body:not(.light) .vm-main .vm-blotter-row > div:first-child, html body:not(.light) .vm-main .vm-blotter.vm-sticky-head > div:first-child { background-color: #213249; }
  html.vm-tenant-deltapay body:not(.light) .vm-main .vm-blotter-row > div:first-child, html.vm-tenant-deltapay body:not(.light) .vm-main .vm-blotter.vm-sticky-head > div:first-child { background-color: #1A1D24; }
  html body .vm-main .vm-blotter-row > div:first-child { margin-left: -20px; padding-left: 20px; }
  html body .vm-main .vm-blotter.vm-sticky-head > div:first-child { margin-left: -20px; padding-left: 20px; }
}

/* A landscape phone is short, not narrow: the bottom bar gives some of it back. */
@media (max-width: 932px) and (max-height: 430px) and (orientation: landscape) {
  .vm-bottomnav button { min-height: 40px; }
}
