/* =====================================================================
 * The phone layer (H, 30 Nov 2026: "I shouldn't be able to swipe this
 * stuff out of screen, it's an app").
 *
 * Loaded after application.css and logistics.css, so it has the last
 * word on a phone and touches nothing above 820px. Three rules:
 *
 *   1. The page never moves sideways. Nothing is wider than the screen.
 *   2. A table is cards: one card per row, each value under its name.
 *      helpers/table_labels.js supplies the names.
 *   3. Forms are one column, controls are thumb sized and full width,
 *      and every gap comes from the same scale: 4, 8, 12, 16, 24.
 *
 * test/integration/phone_layout_test.rb holds the parts a test can.
 * ===================================================================== */

@media (max-width: 820px) {
  /* ---------- 1. The page never moves sideways ---------- */

  /* clip, not hidden: hidden would make a scroll container and break the
     sticky top bar. */
  html, body { overflow-x: clip; overscroll-behavior-x: none; max-width: 100%; }
  #app { grid-template-columns: minmax(0, 1fr); }
  .anon-shell, .anon-card-col { grid-template-columns: minmax(0, 1fr); }
  .anon-card { min-width: 0; }
  .main, .view-root { min-width: 0; max-width: 100%; }
  .view-root { overflow-wrap: break-word; }

  /* A flex or grid child is as wide as its longest word unless told
     otherwise. These are the portal's layout wrappers. */
  .view-root :is(.card, .row, .row-between, .field, .field-row, .field-row-3,
                 .stat-grid, .grid-2, .grid-3, .panel-grid-2) > * { min-width: 0; }
  .view-root :is(.card, section, article, form, fieldset) { max-width: 100%; min-width: 0; }
  .view-root :is(img, video, iframe, canvas) { max-width: 100%; }
  .view-root :is(.input, .select, .textarea, input, select, textarea) { max-width: 100%; }

  /* Rows of mixed things wrap. */
  .view-root :is(.row, .row-between) { flex-wrap: wrap; gap: 8px; }
  .view-root .row > :is(form) { min-width: 0; }

  /* ---------- Top bar: one line, always ---------- */
  .topbar > div:not(.topbar-right) { min-width: 0; flex: 1 1 auto; }
  .topbar h1 { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .topbar-right { flex: none; gap: 8px; }

  /* ---------- Tab strips ---------- */

  /* Every tab is on screen. A strip that does not fit in one line
     becomes two, never a strip to swipe. */
  .view-root .seg-track { display: flex; flex-wrap: wrap; width: fit-content; max-width: 100%; border-radius: 20px; }
  .view-root .seg-item { min-height: 34px; padding: 4px 12px; }
  .view-root .seg-divider { display: none; }
  /* Five tabs, one line, from 360px up. */
  .view-root nav.seg--scout { display: flex; flex-wrap: nowrap; width: 100%; gap: 0; border-radius: 999px; }
  .view-root nav.seg--scout .seg-item { flex: 1 1 auto; justify-content: center; padding: 4px clamp(3px, 1.5vw, 12px); font-size: clamp(11px, 3.1vw, 12.5px); }

  /* ---------- Cards and their headings ---------- */
  .view-root .card:not(.table-card) { padding: 16px; }
  .view-root .card.table-card > .card-title { padding: 14px 16px; margin: 0; }
  .view-root .card-title { flex-wrap: wrap; gap: 4px 12px; line-height: 1.4; }
  .view-root .card-title > small { flex: 0 1 auto; text-align: left; }
  .view-root .card-title .btn { text-transform: none; letter-spacing: 0; }
  .view-root .card.table-card > :is(p, .muted) { padding-inline: 16px; margin-block: 10px; }
  .view-root .card.table-card > .card-title + :is(p, .muted) { margin-top: 12px; }
  .view-root .card > :last-child { margin-bottom: 0; }

  /* ---------- Figures: two abreast, down to the smallest phone ---------- */
  .view-root :is(.stat-grid, :has(> .stat-card ~ .stat-card)) { display: grid !important; grid-template-columns: repeat(2, minmax(0, 1fr)) !important; gap: 10px; width: 100%; }
  .view-root .stat-grid { margin-bottom: 16px; }
  .view-root :has(> .stat-card ~ .stat-card) > :is(:not(.stat-card), .stat-card:nth-child(odd):last-child) { grid-column: 1 / -1; }
  .view-root .stat-grid > .stat-card:only-child { grid-column: 1 / -1; }
  .view-root .stat-card { padding: 14px; min-width: 0 !important; max-width: none !important; }
  .view-root .stat-card .stat-value { font-size: clamp(18px, 5.6vw, 24px); overflow-wrap: break-word; }
  .view-root .stat-card .stat-label { align-items: flex-start; }
  .view-root .stat-card .stat-label::before { margin-top: .42em; }
  .view-root .row-between > .stat-grid { flex: 1 1 100%; }

  /* ---------- 3. Forms ---------- */

  /* Anything holding fields is one column with one gap. :where keeps this
     weaker than any class of its own, so a form with its own layout (or a
     step hidden by a class) is untouched. */
  :where(.view-root) :where(form, fieldset, div:not(.card)):where(:not([hidden])):where(:has(> :is(.field, .field-row, .field-row-3) ~ *, > * ~ :is(.field, .field-row, .field-row-3))) {
    display: flex; flex-direction: column; gap: 16px;
  }
  :where(.view-root) :where(form, fieldset, div:not(.card)):where(:has(> .field)) > :where(.chip, .btn-sm, a:not(.btn)) { align-self: flex-start; }
  :where(.view-root) :where(form, fieldset, div:not(.card)):where(:has(> .field)) > :where(p, .muted, .field-help) { margin-block: 0; }
  .view-root :is(form, fieldset, div:not(.card)):has(> .field ~ .field, > .field ~ .field-row, > .field-row ~ .field) > :is(.field, .field-row, .field-row-3) { margin-block: 0 !important; }
  .view-root :is(form, fieldset, div:not(.card)):has(> .field ~ .field, > .field ~ .field-row, > .field-row ~ .field) { row-gap: 16px; }
  .view-root .address-grid, .view-root .paperwork-vat-custom-form, .view-root .declaration-grid { row-gap: 16px; }
  .view-root .declaration-grid { margin-bottom: 16px !important; }
  .view-root :is(.field-row, .field-row-3, .grid-2, .grid-3) > .field { margin-block: 0 !important; grid-column: 1 / -1 !important; }
  .view-root .field > :is(.muted, .field-help) { margin-top: 0 !important; }
  .view-root form > hr { margin-block: 4px; }
  .view-root .card > .field + .field, .view-root .card > .field + :is(.field-row, .field-row-3),
  .view-root .card > :is(.field-row, .field-row-3) + .field { margin-top: 16px; }

  .view-root :is(.field-row, .field-row-3) { grid-template-columns: minmax(0, 1fr) !important; gap: 16px !important; }
  .view-root .field { gap: 6px; }
  .view-root .field :is(.input, .select, .textarea):not([type=checkbox]):not([type=radio]) { width: 100% !important; max-width: 100% !important; }
  .view-root .field > .field-spacer { display: none; }
  .view-root .field-help { margin-top: 0; }

  /* A tick box and its words sit on one line, centred. */
  .view-root .field label:has(> :is(input[type=checkbox], input[type=radio])) { display: flex; align-items: center; gap: 10px; line-height: 1.35; }
  .view-root :is(input[type=checkbox], input[type=radio]) { flex: none; width: 18px; height: 18px; margin: 0; accent-color: var(--mint-3); vertical-align: middle; }
  .view-root .field > input[type=checkbox] { align-self: flex-start; }

  /* Every control is a thumb's height and speaks the portal's type. */
  .view-root :is(.input, .select):not([multiple]):not([type=checkbox]):not([type=radio]) { min-height: 44px; }
  .view-root select:not([multiple]) {
    appearance: none; -webkit-appearance: none; cursor: pointer;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%231c2d35' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 12px center;
    padding-right: 34px; text-overflow: ellipsis; font-family: inherit;
  }
  :root[data-theme="dark"] .view-root select:not([multiple]) {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23d8e6e2' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  }
  .view-root input:is([type=date], [type=datetime-local], [type=time], [type=month]) { -webkit-appearance: none; appearance: none; min-height: 44px; text-align: left; }
  .view-root input:is([type=date], [type=datetime-local], [type=time], [type=month])::-webkit-date-and-time-value { text-align: left; }
  .view-root input[type=file] { max-width: 100%; font: 400 14px var(--font); color: var(--muted); }
  .view-root input[type=file].input { display: block; width: 100%; padding: 6px; line-height: 32px; min-height: 46px; overflow: hidden; text-overflow: ellipsis; }
  .view-root input[type=file]::file-selector-button {
    margin: 0 10px 0 0; padding: 0 12px; height: 32px;
    border: 1px solid var(--line-2); border-radius: 6px; background: var(--light-2);
    font: 600 13px var(--font); color: var(--ink);
  }

  .view-root .btn { justify-content: center; text-align: center; white-space: normal; }
  .view-root .btn:not(.btn-sm):not(.btn-xs) { min-height: 42px; }
  .view-root .btn-sm { min-height: 34px; }
  .view-root .field > :is(.btn, input[type=submit], button[type=submit]) { width: 100%; min-height: 44px; }
  .view-root :is(.grid-2, .grid-3):has(> .field) { gap: 16px !important; margin-block: 0; }
  .view-root :is(.card, section) > :is(.field, .field-row, .field-row-3, .grid-2, .grid-3):has(.field, .input, .select) + :is(.field, .field-row, .field-row-3, .grid-2, .grid-3) { margin-top: 16px; }
  .view-root :is(.card, section) > .field + :is(.field-row, .field-row-3, .grid-2, .grid-3) { margin-top: 16px; }
  /* Only a form the rule above did not make a flex column: that one has
     its gap already, and a margin on top of it read as 32px. */
  .view-root :is(form, fieldset):not(:has(> :is(.field, .field-row, .field-row-3) ~ *, > * ~ :is(.field, .field-row, .field-row-3))) > :is(.field, .grid-2, .grid-3, .field-row, .field-row-3) + :is(.field, .grid-2, .grid-3, .field-row, .field-row-3) { margin-top: 16px !important; }
  .view-root :is(form, fieldset):has(> :is(.field, .field-row, .field-row-3) ~ *, > * ~ :is(.field, .field-row, .field-row-3)) > :is(.field, .grid-2, .grid-3, .field-row, .field-row-3) { margin-block: 0 !important; }
  .view-root form :is(.field-row, .field-row-3) + :is(.field-row, .field-row-3) { margin-top: 16px !important; }
  .view-root .card > .field + .declaration-grid { margin-top: 16px; }
  .view-root .card > .field:has(+ .declaration-grid) { margin-bottom: 0 !important; }
  .view-root .table td > :is(.btn, form):not(:last-child) { margin-bottom: 6px; }
  .view-root :is(.tool-form, .logistics-form) .field { margin-bottom: 0; }
  .view-root :is(.row, .row-between) > .field { flex: 1 1 100%; min-width: 0 !important; align-self: stretch; }
  .view-root .field > textarea { flex: none; }
  /* Stacked fields anywhere keep the gap, whatever holds them. */
  .view-root .field + .field:not(.field-row > *, .field-row-3 > *, .grid-2 > *, .grid-3 > *, .row > *, .row-between > *, .invoice-register-dates > *) { margin-top: 16px !important; }
  .view-root :is(.row, .row-between):has(> .field + .field) { row-gap: 16px; }
  .view-root .tool-form .field + .field { margin-top: 16px !important; }
  .view-root .form-actions { flex-wrap: wrap; }
  .view-root .form-actions > .btn { flex: 1 1 auto; }
  /* A button straight under a box never touches it. */
  .view-root :is(textarea, .textarea) + :is(.btn, .row, .row-between, div:has(> .btn)) { margin-top: 10px; }
  .view-root form .row > :is(.input, .select) { flex: 1 1 130px; width: auto; }

  /* ---------- Wrapped strips of chips and buttons ---------- */
  .view-root .chip { flex: 0 0 auto; max-width: 100%; white-space: normal; }
  .view-root a.chip { text-decoration: none; }
}

/* ---------- 2. A table is cards ---------- */

@media (max-width: 720px) {
  .view-root .table-card, dialog .table-card { overflow-x: visible; }
  .view-root .card.table-card { overflow: clip; }

  /* Up to three columns fits as a table: it wraps instead of scrolling. */
  :is(.view-root, dialog) :is(.table, .invoice-table, .po-table) { white-space: normal; max-width: 100%; min-width: 0; }
  :is(.view-root, dialog) .table-card .table { white-space: normal; }
  :is(.view-root, dialog) :is(.table, .invoice-table) :is(th, td) { overflow-wrap: break-word; }

  /* The pinned copy of a results header hangs off <body>, not the page:
     cards have no columns for it to name. */
  .scout-sticky-head { display: none !important; }
}

@media (max-width: 720px) {
  :is(.view-root, dialog) table:is(.table-stack, :is(.table, .invoice-table, .po-table):has(> thead > tr > :nth-child(4))):not(.table-keep) {
    & , & > tbody, & > tfoot { display: block; width: 100% !important; min-width: 0 !important; }
    & > colgroup { display: none; }

    /* The header goes, unless it carries the sort links or a select-all:
       those stay as one wrapping line of controls. */
    & > thead { display: none; }
    & > thead:has(a[href], input, select, button:not(.explain-marker)) { display: block; padding: 10px var(--st-x, 12px); border-bottom: 1px solid var(--line); background: var(--light-2); }
    & > thead > tr { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; }
    & > thead > tr > th { display: none; }
    & > thead > tr > th:has(a[href], input, select, button:not(.explain-marker)) { display: block; width: auto !important; padding: 0 !important; border: 0; position: static; box-shadow: none; background: none; text-align: left !important; white-space: normal; }

    & > :is(tbody, tfoot) > tr {
      display: grid;
      grid-template-columns: repeat(2, minmax(0, 1fr));
      gap: 10px 16px;
      position: relative;
      padding: 14px var(--st-x, 0px) !important;
      margin: 0 !important;
      border: 0 !important; border-bottom: 1px solid var(--line) !important; border-radius: 0 !important;
    }
    & > :is(tbody, tfoot) > tr[hidden] { display: none; }
    & > :is(tbody, tfoot):last-child > tr:last-child { border-bottom: 0 !important; }

    & > :is(tbody, tfoot) > tr > :is(td, th) {
      display: block; position: static;
      width: auto !important; min-width: 0 !important; max-width: none !important; height: auto;
      padding: 0 !important; margin: 0;
      border: 0 !important; box-shadow: none !important;
      text-align: left !important; white-space: normal !important;
      overflow-wrap: break-word; background: none;
      font-size: 14px; line-height: 1.45;
    }
    & > :is(tbody, tfoot) > tr > .td-blank { display: none; }
    & > :is(tbody, tfoot) > tr > :is(.td-title, .td-wide, [colspan]) { grid-column: 1 / -1; }
    & > :is(tbody, tfoot) > tr > .td-title { font-size: 15px; font-weight: 600; line-height: 1.35; overflow-wrap: break-word; }
    & > :is(tbody, tfoot) > tr > .td-title .muted { font-weight: 400; }

    & > :is(tbody, tfoot) > tr > [data-label]::before {
      content: attr(data-label); display: block; margin-bottom: 2px;
      font: 700 10px/1.4 var(--font); letter-spacing: .08em; text-transform: uppercase; color: var(--muted);
    }
    & > :is(tbody, tfoot) > tr > :is([data-label=""], .td-title)::before { content: none !important; }

    /* A row's tick box sits in the card's corner. */
    & > :is(tbody, tfoot) > tr > .td-tick { position: absolute !important; top: 14px; right: 16px; z-index: 1; }
    & > :is(tbody, tfoot) > tr:has(> .td-tick) > .td-title { padding-right: 36px !important; }

    /* Attention rows keep the bar down the card's left edge. */
    & > tbody > tr.attention-row { box-shadow: inset 3px 0 0 0 var(--mint); background: rgba(111, 198, 160, .07); }
    & > tbody > tr.attention-row > td { background: none; }

    /* Controls inside a card fill it. */
    & > tbody > tr > td :is(.input, .select, .textarea):not([type=checkbox]):not([type=radio]) { width: 100% !important; max-width: 100% !important; }
    & > tbody > tr > td :is(.row, .row-between) { justify-content: flex-start !important; flex-wrap: wrap; }
    & > tbody > tr > .td-wide form:has(.input, .select) { display: grid; gap: 8px; }
  }

  /* A card of rows insets them; a table inside a padded card does not. */
  .view-root :is(.card.table-card, .lx-table-card) { --st-x: 16px; }
  .view-root .card:not(.table-card) .table:not(:has(> thead > tr > :nth-child(4))) :is(th, td):first-child { padding-left: 0; }
  .view-root .card:not(.table-card) .table:not(:has(> thead > tr > :nth-child(4))) :is(th, td):last-child { padding-right: 0; }
  .view-root .card:not(.table-card) .table-card { border: 0; }
  .view-root .card.table-card .table-card { --st-x: 0px; }
  .view-root .invoice-register-table .table { min-width: 0; }

  /* The header of a stacked table, when it stays, is a sort line: only
     the links and the select-all show. */
  .view-root .table > thead th:has(a[href]) { font-size: 0 !important; }
  .view-root .table > thead th:has(a[href]) a { font-size: 11px; }
  .view-root .table:has(> thead > tr > :nth-child(4)) > thead th :is(.scout-th-sub, .explain) { display: none; }

  /* A list with no header (a file, its date, its state): one block a row. */
  .view-root .table:not(:has(> thead)):has(> tbody > tr > td:nth-child(3)) :is(tbody, tr, td) { display: block; width: auto !important; }
  .view-root .table:not(:has(> thead)):has(> tbody > tr > td:nth-child(3)) { display: block; }
  .view-root .table:not(:has(> thead)):has(> tbody > tr > td:nth-child(3)) tr { padding: 12px 0; border-bottom: 1px solid var(--line); }
  .view-root .table:not(:has(> thead)):has(> tbody > tr > td:nth-child(3)) td { padding: 1px 0 !important; border: 0; text-align: left !important; overflow-wrap: anywhere; }
}

/* ---------- Screens with a shape of their own ---------- */

@media (max-width: 820px) {
  /* Pipelines run down the page: a stage is a section, an empty stage one
     line. Nothing hangs off the right of the screen. */
  .view-root .kanban { grid-template-columns: minmax(0, 1fr); overflow: visible; gap: 10px; }
  .view-root .kanban-col { min-height: 0; }
  .view-root .kanban-col-empty { padding: 6px; text-align: left; }
  .view-root .lx-board { grid-auto-flow: row; grid-auto-columns: minmax(0, 1fr); grid-template-columns: minmax(0, 1fr); overflow: visible; scroll-snap-type: none; gap: 10px; }
  .view-root .lx-column { min-height: 0; }
  .view-root .lx-column:has(> .lx-column-empty) .lx-column-head { padding-bottom: 0; }
  .view-root .lx-column > .lx-column-empty { display: none; }

  /* Toolbars: search on its own line, the rest two abreast. */
  .view-root .staff-deals-toolbar { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; width: 100%; }
  .view-root .staff-deals-toolbar > .row { display: contents; }
  .view-root .staff-deals-toolbar > .row > input { grid-column: 1 / -1; }
  .view-root .staff-deals-toolbar .btn { min-height: 44px; }
  .view-root .staff-deals-toolbar :is(.select, .well-input, .btn) { width: 100%; max-width: none; min-width: 0; }
  .view-root .console-surface :is(.select, .well-input, .well-select):not(.seg-track *) { max-width: none; width: 100%; }
  .view-root form.row:has(> .select) > .select { flex: 1 1 calc(50% - 4px); max-width: none; }

  /* Categories wrap: every one is on screen. */
  /* Amazon USA: the profit figure sits under the words, on the left. */
  .view-root .us-hero-side { text-align: left !important; }

  .view-root .chip-rail { flex-wrap: wrap; overflow: visible; padding: 2px 0; -webkit-mask-image: none; mask-image: none; }

  .view-root .preview-search-form { width: 100%; }
  .view-root .staff-preview-note { margin-left: 0; text-align: left; width: 100%; }

  /* Date ranges: from and to side by side. */
  .view-root .invoice-register-dates { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; align-items: end; }
  .view-root .invoice-register-dates > :not(.field:has(input[type=date])) { grid-column: 1 / -1; }
  .view-root .invoice-register-dates .btn { width: 100%; min-height: 44px; }
  .view-root .invoice-register-head > .btn { width: 100%; }

  /* Applications */
  .view-root .application-facts { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 16px; }
  .view-root .application-facts > * { min-width: 0; overflow-wrap: anywhere; }
  .view-root .application-facts > :has(.mono) { grid-column: 1 / -1; }
  .view-root :has(> .application-decline-form) { display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; }
  .view-root :has(> .application-decline-form) > form:not(.application-decline-form) .btn { width: 100%; }
  .view-root .application-decline-form { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; }
  .view-root .application-decline-form .input { max-width: none; }

  /* Dashboard: the words get the full width, the action sits under them. */
  .view-root .whats-next-row { flex-wrap: wrap; padding: 14px 44px 14px 14px; position: relative; gap: 10px; }
  .view-root .whats-next-row-body { flex: 1 1 100%; }
  .view-root .whats-next-row-actions { width: 100%; justify-content: flex-start; }
  .view-root .whats-next-row-dismiss { position: absolute; top: 8px; right: 6px; }
  .view-root .whats-next-row-age { margin-left: 0; }
  .view-root .card.whats-next-card:not(.table-card) { padding: 0; }
  .view-root .whats-next-header { flex-wrap: wrap; gap: 2px 12px; padding: 14px 16px; }
  .view-root .whats-next-allclear { flex-wrap: wrap; }
  .view-root .whats-next-allclear > :is(.btn, form) { width: 100%; }
  .view-root .whats-next-allclear-body { flex: 1 1 70%; }
  .view-root .dashboard-opportunity { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 8px 14px; padding: 16px; align-items: center; }
  .view-root .dashboard-opportunity-cta { grid-column: 2; justify-self: start; }

  /* Order header: chips in a line, from the left. */
  .view-root .order-modal-chips, dialog .order-modal-chips { align-items: center !important; justify-content: flex-start !important; flex-direction: row !important; flex-wrap: wrap; }

  /* Road to £100M: the section list is one block at the top of the page,
     not a third of the screen that follows you down it. */
  .view-root .road-nav { position: static; padding: 0 0 12px; }
  .view-root .road-section { scroll-margin-top: calc(76px + env(safe-area-inset-top, 0px)); }

  /* Logistics */
  .lx .lx-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .lx .lx-tiles > :last-child:nth-child(odd) { grid-column: 1 / -1; }
  .lx .lx-strip > :last-child:nth-child(3n + 1) { grid-column: 1 / -1; }
  .lx .lx-strip > :last-child:nth-child(3n + 2) { grid-column: span 2; }
  .lx-page > .lx-h2 { margin-top: 24px; }
  .lx :is(.lx-section-card, .lx-next-step) :is(form, .lx-btn, .lx-btn-outline) + :is(form, .lx-btn, .lx-btn-outline) { margin-top: 8px; }

  .view-root .trading-tabs { flex-wrap: nowrap; }
  .view-root .trading-tab { flex: 1 1 auto; padding-inline: 4px; text-align: center; white-space: nowrap; font-size: clamp(11.5px, 3.3vw, 13px); }

  /* FNSKU labels */
  .view-root .fnsku-meta > .row-between { justify-content: flex-start; }
  .view-root .fnsku-print { display: grid; grid-template-columns: 96px minmax(0, 1fr); gap: 8px; width: 100%; }
  .view-root .fnsku-print .input { width: 100% !important; }
  .view-root .fnsku-print [type=submit] { grid-column: 1 / -1; min-height: 42px; }

  /* Deal Scout results */
  .view-root .scout-tab-stack { width: 100%; max-width: 100%; }
  .view-root .scout-backrow { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; }
  .view-root .scout-backrow > * { max-width: 100%; overflow-wrap: anywhere; }

  /* Inputs a view left bare take the portal's box. Type selectors only,
     so any class of their own still wins. */
  :where(.view-root) input:where(:not([type=checkbox], [type=radio], [type=file], [type=range], [type=submit], [type=button], [type=hidden], [type=color])):where(:not([class])), :where(.view-root) select:where(:not([class])) {
    border: 1px solid var(--line-2); border-radius: 6px; background-color: var(--surface); color: var(--ink);
    padding: 0 10px; min-height: 40px; font-family: inherit;
  }
  .view-root .scout-console-input { border: 1px solid var(--line-2); border-radius: 6px; background: var(--surface); color: var(--ink); min-height: 40px; }
  .view-root [data-box-row] { display: grid !important; grid-template-columns: repeat(auto-fit, minmax(78px, 1fr)); gap: 6px !important; margin-bottom: 8px !important; }
  .view-root [data-box-row] > input { width: 100% !important; height: 40px !important; font-size: 16px !important; min-width: 0; }

  .view-root .mkt-want-row { display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; }
  .view-root .mkt-want-row > *, .view-root .mkt-want-note { width: 100%; min-width: 0; height: 44px; font-size: 16px; }

  .view-root .paperwork-vat-export-buttons { position: relative; }
  .view-root .paperwork-vat-custom[open] { flex: 1 1 100%; }
  .view-root .paperwork-vat-custom-form { position: static; margin-top: 10px; width: 100%; min-width: 0; box-shadow: none; }
  .view-root .paperwork-vat-custom-form .btn { width: 100%; min-height: 44px; }

  .view-root .bulk-step1-row > * { flex: 1 1 100%; }
  .view-root .seg-track + .eyebrow:has(+ .seg-track) { display: none; }
  .view-root .card.table-card.sell-through-programme { padding: 16px; --st-x: 0px; }
  .view-root .sell-through-programme .table-card { border: 0; }

}

/* Deal Scout rows as cards: the product's words wrap beside its picture,
   and every figure and control reads from the left like the rest. */
@media (max-width: 720px) {
  .view-root .scout-table-wrap { overflow-x: visible; }
  .view-root .scout-product { min-width: 0 !important; max-width: 100% !important; }
  .view-root .scout-fit-toggle { display: none; }
  .view-root .scout-table-title-tools { margin-left: 0; }
  .view-root .scout-product { align-items: flex-start; }
  .view-root .scout-product > div:not(.scout-compare) { flex: 1 1 0; min-width: 0; }
  .view-root .scout-product:has(.scout-compare) { flex-wrap: wrap; }
  .view-root .scout-product:has(.scout-compare) > div:not(.scout-compare) { flex: 1 1 100%; }
  .view-root :is(.scout-amz-title, .scout-meta, .scout-amz-line) { max-width: 100%; white-space: normal; overflow: visible; overflow-wrap: anywhere; }

  .view-root .scout-items-table :is(.scout-uplift, .scout-us-create) { justify-items: start; white-space: normal; }
  .view-root .scout-items-table .scout-plan { justify-items: start; min-width: 0; }
  .view-root .scout-items-table :is(.scout-plan-rec, .scout-plan-notice) { margin-left: 0; text-align: left; max-width: 100%; }
  .view-root .scout-items-table .scout-plan-form { display: grid; grid-template-columns: 72px 110px auto; gap: 8px; align-items: center; }
  .view-root .scout-items-table .scout-plan-form .scout-cell-lbl { white-space: normal; line-height: 1.25; }
  .view-root .scout-items-table :is(.scout-removal, .scout-removal-form) { justify-content: flex-start; }
  .view-root .scout-items-table .scout-removal-when { text-align: left; }
  /* The caption row under the header names columns a card does not have,
     and each group of sort links says what it sorts. */
  .view-root .scout-items-table .scout-th-subrow { display: none !important; }
  .view-root .scout-items-table > thead th[data-phone-label]::before { content: attr(data-phone-label) ": "; font: 600 11px var(--font); letter-spacing: 0; text-transform: none; color: var(--muted); }
  .view-root .scout-items-table > thead th .scout-th-sort { font-size: 0; display: inline-flex; gap: 8px; vertical-align: baseline; }
  .view-root .scout-items-table > thead th br { display: none; }
  .view-root .scout-items-table :is(.scout-plan-margin, .scout-plan-rec summary) { white-space: normal; }
  .view-root .scout-items-table .scout-uplift-why { justify-self: start; }
  .view-root .scout-items-table .scout-uplift-why ul { max-width: 100%; }
  .view-root .scout-items-table td :is(.scout-cell-ctl, .scout-range-buttons) { justify-content: flex-start; }
  .view-root .scout-items-table td.scout-action-cell { white-space: normal; }
  .view-root .scout-items-table td :is(.scout-us-uplift-roi, .scout-range-in, .scout-sell-price-readout) { white-space: normal; }

  /* Name on the left, box the same width on every line. */
  .view-root .scout-items-table .scout-us-create { width: 100%; gap: 8px; }
  .view-root .scout-items-table .scout-us-create label { display: grid; grid-template-columns: 72px 110px; gap: 8px; align-items: center; }
  .view-root .scout-items-table .scout-cell-ctl { display: grid; grid-template-columns: 72px 110px auto; gap: 8px; align-items: center; width: max-content; max-width: 100%; margin-top: 6px; }
  .view-root .scout-items-table td :is(.scout-us-create label, .scout-cell-ctl, .scout-plan-form) :is(input:not([type=hidden]):not([type=submit]):not([type=checkbox]), select) {
    width: 110px !important; height: 40px !important; min-height: 40px; padding: 0 10px !important;
    border: 1px solid var(--line-2); border-radius: 6px; background-color: var(--surface); color: var(--ink); font: 400 16px var(--font) !important;
  }
  .view-root .scout-items-table td .scout-cell-ctl select { padding-right: 28px !important; }
  .view-root .scout-items-table .scout-cell-ctl input[type=submit] { width: auto !important; min-height: 40px; }
}

/* A sheet opened by a tap is not a keyboard focus: no ring round it. */
@media (pointer: coarse) {
  dialog:focus, dialog:focus-visible, dialog [aria-label="Close"]:focus-visible { outline: none; }
}

/* Not only on a phone: faults that showed on a desktop too. */
.signed-in-devices { list-style: none; margin: 0; padding: 0; }
.card-title .btn { text-transform: none; letter-spacing: 0; }
.table .well-input, textarea.well-input { background-image: none; padding-left: 12px; padding-right: 12px; }
textarea.well-input { height: auto; padding-top: 10px; padding-bottom: 10px; }
.stat-card.navy .explain-marker { background: var(--surface); border-color: var(--line-2); color: var(--muted); }
.btn-secondary { background: var(--surface); border-color: var(--line-2); color: var(--ink); }
/* The count sits on the bell button's corner, not over the bell. */
.notification-dot { top: -6px; right: -6px; }
