/* Add LAST, after mypanel-native-palette.css. Presentation only.
   Mobile cards follow DOM order; tables retain their headings and own scrolling.
   No desktop rules, data selectors, hidden-state overrides or global SVG sizing. */
@media (max-width:900px) {
  html body {
    --mp-mobile-rail:58px;
    --mp-icon-card:24px;
    --mp-icon-disc:38px;
    --mp-icon-heading:26px;
    --mp-icon-tab:20px;
    --mp-icon-method:22px;
    --mp-icon-method-disc:36px;
    --mp-font-body:14px;
    --mp-font-title:15px;
    --mp-font-value:28px;
    --mp-font-note:12px;
  }
  html body .app-side { width:var(--mp-mobile-rail);padding:12px 5px; }
  html body .brand { padding:0 0 12px;text-align:center; }
  html body .brand b { font-size:0; }
  html body .brand b:first-letter { font-size:26px; }
  html body .brand small,html body .mp-primary>button>span,html body .side-foot { display:none; }
  html body .mp-primary>button { padding:10px 7px;min-height:48px;gap:0;justify-content:center; }
  html body .mp-primary>button .ov-icon { width:24px;height:24px;flex:none; }
  /* Natural height prevents long station/cultivar names overlapping the page. */
  html body .app-top {
    position:relative;left:auto;right:auto;top:auto;margin-left:var(--mp-mobile-rail);
    width:auto;height:auto;min-height:0;padding:10px;gap:8px;flex-wrap:wrap;overflow:visible;
  }
  html body .app-top>* { order:initial; }
  html body .app-top .top-select:first-child,html body .app-top .mp-variety {
    flex:1 1 100%;width:100%;max-width:100%;min-width:0!important;height:auto;min-height:52px;
  }
  html body .app-top .top-select select { font-size:14px;min-height:30px;max-width:100%; }
  html body .app-top .panel-theme-switch,html body .app-top .mp-snapshot,
  html body .app-top .mp-export,html body .app-top .top-user {
    flex:1 1 90px;width:auto;min-width:0;max-width:100%;height:auto;min-height:44px;
  }
  html body .app-top .panel-theme-switch button { min-height:38px;height:auto; }
  html body .app-top .top-user { white-space:normal;overflow-wrap:anywhere; }
  html body .page { margin-left:var(--mp-mobile-rail);padding:16px 10px 40px;min-width:0; }
  html body .page :is(section,article,header,footer,form,fieldset,dl,details) { min-width:0; }
  html body .page :is(h1,h2,h3,h4,p,dt,dd,label,small,strong) { overflow-wrap:anywhere; }
  html body .page :is(button,select,input,textarea) { max-width:100%; }
  html body .page :is(button,select) { min-height:44px; }
  html body .page :is(.mp-heading,.mps-heading,.mp-section-title,.mp-m-panel>h2) { flex-wrap:wrap;gap:8px; }
  html body .page :is(.mp-heading,.mps-heading) h1 { font-size:24px;line-height:1.3; }
  html body .page :is(.mp-heading,.mps-heading) p { font-size:14px;line-height:1.5; }
  html body .page .ov-icon { width:var(--mp-icon-card);height:var(--mp-icon-card);flex-shrink:0; }
  html body .page :is(.mp-heading,.mps-heading)>.ov-icon { width:var(--mp-icon-heading);height:var(--mp-icon-heading); }
  html body .page .mp-icon-disc { width:var(--mp-icon-disc);height:var(--mp-icon-disc);flex:none; }
  html body .page .mp-icon-disc .ov-icon { width:var(--mp-icon-card);height:var(--mp-icon-card); }
  html body .page :is(.mp-section-meta,.mp-text-button) { font-size:12px;max-width:100%;white-space:normal; }
  html body .page :is(.mps-tabs,.mp-m-tabs,.set-tabs) { flex-wrap:wrap; }
  html body #view-indices>.mps-tabs>button { flex:1 1 130px;white-space:normal; }
  html body #view-crops>.mps-crop-nav { grid-template-columns:repeat(2,minmax(0,1fr)); }
  html body #view-settings .set-tabs button { flex:1 1 130px;min-width:0;white-space:normal; }

  /* Main sections stack before nested cards; no named-area visual reordering. */
  html body #view-overview .mp-overview-grid { grid-template-columns:minmax(0,1fr);grid-template-areas:none; }
  html body #view-overview .mp-overview-grid>* { grid-area:auto; }
  html body .mp-m-columns,html body #mps-indices-micro .mcm-layout,
  html body #view-indices .mpi-grid.bottom,html body #view-indices .mpi-grid.two,
  html body #mpcProtection .mpc-protection-grid,html body #mpcNutrition.mpn-photo .mpn-two-panel,
  html body .mp-ir-middle,html body #view-reports .rep-bottom,html body #view-reports .rep-visual-grid {
    grid-template-columns:minmax(0,1fr);
  }
  html body[data-mps-crop="phenology"] #view-crops,
  html body[data-mps-crop="phenology"] #mpcPhenology { display:block; }
  html body[data-mps-crop="phenology"] #mpcPhenology>* { margin-bottom:12px!important; }
  html body #view-overview .mp-overview-grid .mp-reading-grid,html body #view-overview .mp-hardware-grid,
  html body #view-overview .mp-annual-grid,html body .mp-m-reading-grid,html body .mp-m-summary,
  html body #view-indices .mpi-grid.four,html body #view-indices .mpi-grid.three,
  html body #mpsCropSummary .mpc-summary-readings,html body #mpsCropSummary .mpc-management-grid,
  html body #mpcPhenology .mpc-phen-readings,html body .mp-ir-summary,
  html body #view-forecast .mpf-summary,html body #view-reports .rep-types {
    grid-template-columns:repeat(2,minmax(0,1fr));gap:12px;
  }
  html body #mpcCalendarClone .cal-stats,html body #mpcCalendarClone .cal-months {
    grid-template-columns:repeat(2,minmax(0,1fr));gap:12px;overflow:visible;
  }
  html body #mpcCalendarClone .cal-stats>section { grid-row:auto;grid-column:auto; }
  html body #mpcCalendarClone .cal-stats>.cal-reading-guide { grid-column:1/-1; }
  html body #mpcCalendarClone .cal-year { flex-direction:row;flex-wrap:wrap; }
  html body #mpcCalendarClone .cal-year>svg { width:64px;height:64px;flex:none; }
  html body #mpcCalendarClone .cal-month { overflow:visible; }
  html body #mpcCalendarClone :is(.cal-month li,.cal-source-links a,.cal-month details>p,.cal-stats small) { font-size:12px;line-height:1.6; }
  html body #mpcCalendarClone .cal-month-head>div { min-width:0; }
  html body #mpcCalendarClone .cal-current { position:static;margin-left:auto;white-space:normal; }

  /* Metric content is a sequence of automatic rows, never a fixed-height value lane. */
  html body #view-overview .mp-overview-grid .mp-reading,html body .mp-m-reading-grid .mp-reading,
  html body #view-indices .mps-card,html body #view-crops .mpc-reading-card,
  html body #view-forecast .mpf-summary .mpf-card {
    display:flex;flex-direction:column;align-items:flex-start;justify-content:flex-start;
    gap:7px;padding:12px;min-height:0;height:auto;text-align:left;
  }
  html body #view-overview .mp-overview-grid .mp-reading>*,html body .mp-m-reading-grid .mp-reading>*,
  html body #view-indices .mps-card>*,html body #view-crops .mpc-reading-card>*,
  html body #view-forecast .mpf-summary .mpf-card>* {
    position:static;inset:auto;order:initial;grid-area:auto;min-width:0;max-width:100%;
    margin:0;white-space:normal;overflow-wrap:anywhere;align-self:auto;
  }
  html body #view-overview .mp-overview-grid .mp-reading>.mp-icon-disc,
  html body .mp-m-reading-grid .mp-reading>.mp-icon-disc,
  html body #view-indices .mps-card>.mp-icon-disc,
  html body #view-crops .mpc-reading-card>.mp-icon-disc,
  html body #view-forecast .mpf-summary .mpf-card>.mp-icon-disc {
    width:var(--mp-icon-disc);height:var(--mp-icon-disc);
  }
  html body #view-overview .mp-overview-grid .mp-reading>b,html body .mp-m-reading-grid .mp-reading>b,
  html body #view-indices .mps-card>b,html body #view-crops .mpc-reading-card>b,
  html body #view-forecast .mpf-summary .mpf-card>b { font-size:var(--mp-font-value);line-height:1.35; }
  html body #view-overview .mp-overview-grid .mp-reading h3,html body .mp-m-reading-grid .mp-reading h3 { font-size:15px;padding:0;min-height:0;width:auto; }
  html body #view-overview .mp-overview-grid .mp-reading p,html body .mp-m-reading-grid .mp-reading p { font-size:12px;line-height:1.5; }
  html body .page .mp-badge { white-space:normal;overflow-wrap:anywhere;max-width:100%;font-size:10px; }
  html body #view-overview .mp-overview-grid .mp-reading>.mp-badge { display:block; }
  html body #view-overview .mp-crop-values b { white-space:normal;overflow-wrap:anywhere; }
  html body .mp-ir-summary .mp-ir-tile>div { grid-template-rows:repeat(5,auto);gap:6px; }
  html body .mp-ir-summary .mp-ir-tile { grid-template-columns:var(--mp-icon-disc) minmax(0,1fr); }
  html body .mp-ir-value,html body .mp-ir-badge { white-space:normal;overflow-wrap:anywhere; }
  html body .mp-ir-equation { flex-wrap:wrap;justify-content:flex-start;row-gap:12px; }
  html body #mpcProtection .mpc-target-card { grid-template-columns:minmax(0,1fr); }
  html body #mpcProtection .mpc-target-photo { max-width:100%; }
  html body #mpcProtection .mpc-protection-conditions article { grid-template-columns:24px minmax(0,1fr); }
  html body #mpcProtection .mpc-protection-conditions article>b { grid-column:2; }
  html body #mpcProtectionDetail .mpc-protection-detail-grid { grid-template-columns:minmax(0,1fr); }

  /* Data tables retain semantics and headings; scroll only their local wrapper. */
  html body .page :is(.mps-table-wrap,.mp-m-table-wrap,.ov-forecast-scroll,.rep-table-wrap,
    .ss-table-wrap,.sc-table-wrap,.sd-table-wrap,.quality-table-wrap,.health-table-wrap,
    .cmp-table-wrap,.as-reader-table-wrap) { max-width:100%;min-width:0;overflow-x:auto; }
  html body .page :is(.set-grid,.ss-grid,.sys-grid,.nt-grid,.as-reader-grid,
    .cv-grid,.cv-notes,.cv-field-grid,.as-field-grid,.as-password-grid) { grid-template-columns:minmax(0,1fr); }
  html body #settingsGeneral .set-grid,html body #settingsNotifications .nt-grid,
  html body #settingsStationsPanel .ss-grid,html body #settingsSystemPanel .sys-grid { grid-template-columns:minmax(0,1fr); }
  html body dialog { max-width:calc(100vw - 20px);max-height:calc(100dvh - 20px);padding:14px;overflow-y:auto; }
}

@media (max-width:600px) {
  /* One readable tile per line on phones; 768px tablets retain two useful tracks. */
  html body #view-overview .mp-overview-grid .mp-reading-grid,html body #view-overview .mp-hardware-grid,
  html body #view-overview .mp-annual-grid,html body #view-overview .mp-crop-values,
  html body .mp-m-reading-grid,html body .mp-m-summary,html body .mp-m-history-controls,
  html body .mps-grid.four,html body .mps-grid.three,html body .mps-grid.two,
  html body #view-indices .mpi-grid.four,html body #view-indices .mpi-grid.three,
  html body #mps-indices-micro .mcm-reading-grid,html body #mps-indices-micro .mcm-season-grid,
  html body #mpsCropSummary .mpc-summary-readings,html body #mpsCropSummary .mpc-management-grid,
  html body #mpcPhenology .mpc-phen-readings,html body #mpcPhenology .stage-track,
  html body .mp-ir-summary,html body .mp-ir-data-grid,html body #view-forecast .mpf-summary,
  html body #mpcProtection .mpc-protection-summary,html body #mpcProtection .mpc-protection-conditions,
  html body #mpcCalendarClone .cal-stats,html body #mpcCalendarClone .cal-months,
  html body #view-reports .rep-types,html body #view-reports .rep-formats,
  html body #settingsGeneral #settingsForm {
    grid-template-columns:minmax(0,1fr);gap:12px;
  }
  html body #mpcCalendarClone .cal-stats>.cal-reading-guide { grid-column:auto; }
  html body #view-forecast .mpf-spray { grid-column:auto; }
  html body .mp-m-station>div,html body .mps-details>div { grid-template-columns:minmax(0,1fr);gap:5px; }
  html body #view-indices .mpi-linkage { grid-template-columns:minmax(0,1fr); }
  html body #view-indices .mpi-linkage>div+div { border-left:0;padding-left:0; }
}
