/* Screen density only: native pinch zoom and printed documents stay intact. */
@media screen {
  :root {
    --prima-ui-scale:1;
    --prima-ui-viewport-width:100vw;
    --prima-ui-viewport-height:100dvh;
    --prima-safe-top:env(safe-area-inset-top,0px);
    --prima-safe-right:env(safe-area-inset-right,0px);
    --prima-safe-bottom:env(safe-area-inset-bottom,0px);
    --prima-safe-left:env(safe-area-inset-left,0px);
  }
  /* Keep editable text readable and prevent focus zoom on phones. */
  html.prima-ui-mobile { --prima-control-size:20px; }
  html.prima-ui-mobile body.prima-ui :is(input:not([type=checkbox]):not([type=radio]):not([type=range]):not([type=hidden]):not([type=color]),select,textarea):not(.print-sheet *,#archiveReportPreview *) {
    min-height:2.5em;
  }
  /* These surfaces intentionally fill the viewport rather than shrinking with
     the contents. Percentage widths still fill the available inline space. */
  html:root.prima-ui-mobile:not(.prima-ui-embedded) body.prima-ui #mobileMoreSheet .mobile-sheet-panel {
    height:var(--prima-ui-viewport-height);
    max-height:var(--prima-ui-viewport-height);
    padding-top:calc(16px + var(--prima-safe-top));
    padding-bottom:calc(100px + var(--prima-safe-bottom));
  }
  html:root.prima-ui-mobile:not(.prima-ui-embedded) body.prima-ui #mobileNav {
    padding-bottom:calc(8px + var(--prima-safe-bottom));
  }
  html:root.prima-ui-mobile:not(.prima-ui-embedded) body.prima-ui:not(#archiveReportPreview) #appHeader {
    padding-top:max(10px,var(--prima-safe-top));
    padding-left:max(16px,var(--prima-safe-left));
    padding-right:max(16px,var(--prima-safe-right));
  }
  html:root.prima-ui-mobile:not(.prima-ui-embedded) body.prima-ui:not(#archiveReportPreview)>.app {
    padding-bottom:calc(100px + var(--prima-safe-bottom));
  }
  html:root.prima-ui-mobile:not(.prima-ui-embedded) body.prima-ui:not(#archiveReportPreview)>.app>.view:not(:has(>iframe)),
  html:root.prima-ui-mobile:not(.prima-ui-embedded).workspace-document body>main,
  html:root.prima-ui-mobile:not(.prima-ui-embedded) body.prima-ui.essential-page:not(#archiveReportPreview),
  html:root.prima-ui-mobile:not(.prima-ui-embedded) body.prima-ui:not(#archiveReportPreview)>main.essential-page {
    padding-left:max(var(--mobile-page-inset,16px),var(--prima-safe-left));
    padding-right:max(var(--mobile-page-inset,16px),var(--prima-safe-right));
  }
  html:root.prima-ui-mobile:not(.prima-ui-embedded) body.prima-ui:not(#archiveReportPreview):has(#cashRegisterView.active)>.app {
    height:var(--prima-frame-viewport-height,var(--prima-ui-viewport-height));
    padding-bottom:0!important;
  }
  html:root.prima-ui-mobile:not(.prima-ui-embedded) body.prima-ui:not(#archiveReportPreview):has(#editorView.active>#bancoVenditaFrame:not([hidden]))>.app {
    padding-bottom:var(--banco-frame-bottom-inset,calc(100px + var(--prima-safe-bottom)));
  }
  html:root.prima-ui-mobile:not(.prima-ui-embedded) dialog {
    max-height:calc(var(--prima-ui-viewport-height) - 24px);
  }
  html:root.prima-ui-mobile:not(.prima-ui-embedded) body .prima-picker-panel {
    max-width:calc(var(--prima-ui-viewport-width) - 24px);
  }
  /* Native calendar indicators need their own room beside 16px rendered text.
     Only these compact filter rows grow; their existing wrapping stays intact. */
  html:root.prima-ui-mobile body.prima-ui:not(#archiveReportPreview) #homeSalesWidget .home-sales-filters {
    grid-template-columns:repeat(auto-fit,minmax(min(100%,230px),1fr));
  }
  html:root.prima-ui-mobile body.prima-ui :is(#windtreDailyRaceView,#veryDailyRaceView).daily-race-layout :is(.wd-actions,.vd-actions) {
    --daily-race-action-height:58px;
  }
  html:root.prima-ui-mobile body.prima-ui :is(#windtreDailyRaceView,#veryDailyRaceView).daily-race-layout :is(.wd-date,.vd-date) {
    flex:1 1 240px;
    max-width:100%;
  }
  html:root.prima-ui-mobile body.prima-ui :is(#windtreDailyRaceView,#veryDailyRaceView).daily-race-layout :is(.wd-date,.vd-date) input {
    min-width:180px;
    flex:1 1 180px;
  }
}

/* Responsive surfaces also cover an open Fold and a rotated handset. Keep
   intrinsic document height and let rows wrap instead of clipping the page. */
@media screen {
  .sf-axis-name {display:none}
  html:root.prima-ui-mobile body.prima-ui:not(#archiveReportPreview) :is(.view,.essential-page,main,.card,.panel,.home-widget,.home-work-area,.home-work-left,.field,.form-grid,.filters,.toolbar) {min-width:0;box-sizing:border-box}
  html:root.prima-ui-mobile body.prima-ui:not(#archiveReportPreview) :is(.essential-heading,.page-heading,.section-head,.review-head,.filters,.actions,.toolbar) {max-width:100%;flex-wrap:wrap}
  html:root.prima-ui-mobile body.prima-ui:not(#archiveReportPreview) :is(input,select,textarea) {max-width:100%;box-sizing:border-box}
  html:root.prima-ui-mobile body.prima-ui:not(#archiveReportPreview) :is(.table-scroll,.table-wrap,.table-container) {max-width:100%;overflow-x:auto;overscroll-behavior-inline:contain}
  html:root.prima-ui-mobile body.prima-ui:not(#archiveReportPreview) dialog {box-sizing:border-box;max-width:calc(100% - 24px);overflow:auto}
  html:root.prima-ui-mobile body.prima-ui:not(#archiveReportPreview) :is(.home-widget-head,.section-head,.essential-heading)>:not(button) {min-width:0;overflow-wrap:anywhere}

  html:root.prima-ui-mobile body.prima-ui:not(#archiveReportPreview) #strengthView .radar {display:block;flex:none;height:auto;min-height:0;container-type:normal}

  /* The map and its values use separate rows: six named axes,
     followed by readable values, even on a narrow external Fold display. */
  html:root.prima-ui-mobile body.prima-ui:not(#archiveReportPreview) :is(#homeSalesWidget,#strengthView) .sf-hud-chart {
    display:flex;flex-direction:column;gap:12px;position:relative;
    width:100%;height:auto;min-height:0;aspect-ratio:auto;margin:8px 0 12px;
  }
  html:root.prima-ui-mobile body.prima-ui:not(#archiveReportPreview) :is(#homeSalesWidget,#strengthView) .sf-hud-chart>svg {
    display:block;position:static;inset:auto;transform:none;
    width:min(100%,420px);height:auto;max-height:none;align-self:center;
  }
  html:root.prima-ui-mobile body.prima-ui:not(#archiveReportPreview) :is(#homeSalesWidget,#strengthView) .sf-hud-axis-list {
    position:static;display:grid;grid-template-columns:repeat(auto-fit,minmax(min(100%,180px),1fr));gap:10px;pointer-events:auto;
  }
  html:root.prima-ui-mobile body.prima-ui:not(#archiveReportPreview) :is(#homeSalesWidget,#strengthView) .sf-hud-lane {
    position:static;inset:auto;transform:none;width:auto;min-width:0;min-height:60px;padding:10px;
    align-items:flex-start;text-align:left;border:1px solid var(--sf-hud-line);background:var(--sf-hud-bg);gap:5px;
  }
  html:root.prima-ui-mobile body.prima-ui:not(#archiveReportPreview) :is(#homeSalesWidget,#strengthView) .sf-hud-lane-name {font-size:14px!important;line-height:1.4!important;overflow-wrap:anywhere}
  html:root.prima-ui-mobile body.prima-ui:not(#archiveReportPreview) :is(#homeSalesWidget,#strengthView) .sf-hud-lane strong {font-size:26px!important;line-height:1.2!important}
  html:root.prima-ui-mobile body.prima-ui:not(#archiveReportPreview) :is(#homeSalesWidget,#strengthView) .sf-hud-lane-estimate {font-size:13px!important}
  html:root.prima-ui-mobile svg .sf-axis-name {display:inline;font-size:19px;font-weight:650;fill:var(--sf-hud-ink);paint-order:stroke;stroke:var(--sf-hud-bg);stroke-width:5px;stroke-linejoin:round}
  html:root.prima-ui-mobile svg .sf-axis-over {fill:#18754a}
  html:root.prima-ui-mobile svg .sf-axis-forecast-over {fill:var(--sf-hud-orange)}
  html:root.prima-ui-mobile body.prima-ui:not(#archiveReportPreview) #homeSalesWidget .sf-hud-axis-list {display:none}
  html:root.prima-ui-mobile body.prima-ui:not(#archiveReportPreview) #homeSalesWidget .home-performance-card {min-height:0;height:auto;margin:10px 0;padding:0;flex:none}
  html:root.prima-ui-mobile body.prima-ui:not(#archiveReportPreview) #homeSalesWidget .home-performance-legend {font-size:13px!important;gap:8px 14px}
  html:root.prima-ui-mobile body.prima-ui:not(#archiveReportPreview) #homeSalesWidget .home-performance-summary {
    display:grid;grid-template-columns:repeat(auto-fit,minmax(min(100%,150px),1fr));gap:10px;
  }
  html:root.prima-ui-mobile body.prima-ui:not(#archiveReportPreview) #homeSalesWidget .home-performance-summary>div {padding:12px;border:1px solid #dce7ef;border-radius:12px;background:var(--prima-screen-surface,#f7fafc);min-width:0}
  html:root.prima-ui-mobile body.prima-ui:not(#archiveReportPreview) #homeSalesWidget .home-performance-summary span {font-size:13px!important;line-height:1.4!important;gap:6px;min-height:2.8em;overflow-wrap:anywhere}
  html:root.prima-ui-mobile body.prima-ui:not(#archiveReportPreview) #homeSalesWidget .home-performance-summary strong {font-size:24px!important;line-height:1.2!important;margin:6px 0}
  html:root.prima-ui-mobile body.prima-ui:not(#archiveReportPreview) #homeSalesWidget .home-performance-summary small {font-size:13px!important;line-height:1.5!important}
  html:root.prima-ui-mobile body.prima-ui:not(#archiveReportPreview) #homeSalesWidget #homeSalesExtras {grid-template-columns:repeat(auto-fit,minmax(min(100%,160px),1fr))}
}
@media screen {
  /* Anchor the report's visually hidden caption to its scrolling table. */
  html.prima-ui-mobile .ae-table-wrap {position:relative;min-width:0;max-width:100%;contain:inline-size}
}
@media screen {
  html.prima-ui-mobile .ae-sr-only {top:0;left:0;clip-path:inset(50%)}
}
@media screen {
  html.prima-ui-mobile .library-stats {grid-template-columns:repeat(auto-fit,minmax(min(100%,160px),1fr))}
  html.prima-ui-mobile .library-stat {min-width:0;overflow-wrap:anywhere}
}
@media screen {
  @container home-sales (min-width:650px) {
    html:root.prima-ui-mobile body.prima-ui:not(#archiveReportPreview) #homeSalesContent:not([hidden]) {display:grid;grid-template-columns:minmax(0,.9fr) minmax(0,1.1fr);gap:16px;align-items:center}
    html:root.prima-ui-mobile #homeSalesContent>.home-sales-total {grid-column:1/-1}
    html:root.prima-ui-mobile #homeSalesWidget .home-performance-card {grid-column:1;grid-row:2}
    html:root.prima-ui-mobile body.prima-ui:not(#archiveReportPreview) #homeSalesWidget .home-performance-summary {grid-column:2;grid-row:2;grid-template-columns:repeat(2,minmax(0,1fr))}
    html:root.prima-ui-mobile #homeSalesContent>:is(.home-sales-extras,.home-sales-composition-note) {grid-column:1/-1}
  }
}
