/* Shared mobile shell and component adaptations. Desktop styles remain in style.css. */
.mobile-nav, .mobile-filters-toggle, .inbox-back { display: none; }
/* In our iOS/Android apps (see MobileApp) the native shell draws its own chrome,
   so .app-hidden elements go and the space kept for the bottom bar collapses. */
html.is-mobile-app .app-hidden { display: none !important; }

@media (width < 768px) {
  :root { --mobile-nav-height: 4rem; --ctl-h: 2.75rem; }
  html.is-mobile-app { --mobile-nav-height: 0rem; }
  .app, .main-col, .page, .page-head > *, .card, .card-body { min-width: 0; }
  .page { padding-bottom: calc(var(--mobile-nav-height) + env(safe-area-inset-bottom) + 1.5rem); }
  .topbar { padding-top: max(.5rem, env(safe-area-inset-top)); padding-inline: .75rem; gap: .35rem; }
  .topbar > .d-flex { gap: .5rem !important; }
  .page-head { gap: .85rem; }
  .page-title { font-size: 1.4rem; }
  .page-sub { line-height: 1.5; overflow-wrap: anywhere; }
  .page-actions { width: 100%; min-width: 0; flex-wrap: wrap; gap: .5rem; }
  .page-actions > :is(a, button) { justify-content: center; flex: 1 1 auto; white-space: normal; }
  .btn-icon, .ctl-icon, .btn-outline.topbar-new { min-width: 2.75rem; min-height: 2.75rem; }
  :is(.btn-solid, .btn-outline, .seg-btn, .acct-tab, .ps-tab, .menu-item, .side-link, .side-sublink) { min-height: 2.75rem; }
  :is(input:not([type="checkbox"], [type="radio"]), select, textarea) { font-size: 1rem !important; }
  .form-adorn { min-width: 0; }
  .card-head { padding: 1rem; gap: .75rem; }
  .card-body { padding: 1rem; }
  .card-foot { padding: .85rem 1rem; }
  .table-foot { flex-wrap: wrap; gap: .75rem; }
  .mobile-nav { position: fixed; inset: auto 0 0; z-index: 35; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); padding: .3rem max(.35rem, env(safe-area-inset-right)) calc(.3rem + env(safe-area-inset-bottom)) max(.35rem, env(safe-area-inset-left)); min-height: var(--mobile-nav-height); border-top: 1px solid var(--cad-rule); background: var(--bs-bg-body); }
  .mobile-nav-item { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .25rem; min-height: 3.15rem; border: 0; border-radius: .5rem; padding: .35rem .1rem; background: none; color: var(--bs-fg-3); font-size: .65rem; font-weight: 600; text-decoration: none; }
  .mobile-nav-item[aria-current="page"], .mobile-nav-item.is-active { background: color-mix(in oklab, var(--bs-primary-base), transparent 90%); color: var(--bs-primary-fg-emphasis); }
  .mobile-nav-item:focus-visible { outline: 2px solid var(--bs-primary-base); outline-offset: -2px; }
  #navDrawer { max-width: min(21rem, calc(100vw - 2rem)); }
  #navDrawer .drawer-body { padding-bottom: max(1rem, env(safe-area-inset-bottom)); }
  .mobile-filters-toggle { display: inline-flex; align-items: center; justify-content: center; min-height: 2.75rem; width: 100%; }
  .has-mobile-filters { align-items: stretch; }
  .has-mobile-filters > .seg { width: 100%; }
  .rp-filter-fields[hidden] { display: none !important; }
  .rp-filter-fields { gap: .65rem; }
  .rp-filter-fields .ctl { min-height: 2.75rem; }
  .seg { max-width: 100%; overflow-x: auto; scrollbar-width: thin; flex-wrap: nowrap; }
  .seg-btn { flex: 0 0 auto; }
  .ctl-pop { max-height: min(32rem, 70dvh); overflow-y: auto; max-width: calc(100vw - 2rem); }
  .date-custom { min-width: 0; }
  .date-custom input { min-width: 0; width: 100%; }
  .notif-menu { width: calc(100vw - 1.5rem); max-width: calc(100vw - 1.5rem); }
  .notif-list { max-height: 55dvh; }
  /* Calendar: title and actions on one line, the toolbar in two rows
     (dates; properties and view), so the grid starts higher. */
  .cal-head { flex-wrap: nowrap; align-items: flex-start; }
  .cal-head .page-actions { width: auto; flex: none; }
  .cal-head-label, .cal-view-text { display: none; }
  .cal-toolbar { align-items: stretch; flex-direction: column; gap: .5rem; padding-block: .75rem; }
  .cal-toolbar .toolbar-group { flex-wrap: nowrap; max-width: 100%; gap: .5rem; margin-left: 0; }
  .cal-toolbar .ctl-group, .cal-toolbar .date-pick, .cal-toolbar .prop-pick { flex: 1 1 auto; min-width: 0; }
  .cal-toolbar .cal-range-btn, .cal-toolbar .prop-pick-btn { width: 100%; min-width: 0; }
  .cal-toolbar .seg { flex: 1 1 100%; }
  .cal-card { --left: 7.75rem; }
  .cal-tape { overscroll-behavior-x: contain; touch-action: pan-x pan-y; }
  .cal-tape.can-scroll-right { box-shadow: inset -10px 0 10px -10px color-mix(in oklab, var(--bs-fg-body), transparent 55%); }
  /* Room for the name; settings are on the Properties page. */
  .cal-property-settings { display: none; }
  .cal-legend-hint { display: none; }
  .cal-legend { gap: .5rem .75rem; padding: .85rem 1rem; font-size: .72rem; }
  .dialog { max-width: calc(100vw - 1rem); max-height: calc(100dvh - 1rem); }
  .ps-dialog { --bs-dialog-width: 100vw; width: 100%; max-width: 100%; height: 100dvh; max-height: 100dvh; margin: 0; border-radius: 0; }
  .ps-dialog .bk-form { height: 100%; }
  .ps-dialog .dialog-header { flex: none; padding: max(1rem, env(safe-area-inset-top)) 1rem 1rem; }
  .ps-dialog .ps-body { flex: 1; min-height: 0; grid-template-rows: auto minmax(0, 1fr); }
  .ps-dialog .ps-nav { padding: .65rem 1rem; overscroll-behavior-x: contain; }
  .ps-dialog .ps-tab { flex: none; }
  .ps-dialog .ps-panels { min-height: 0; overflow-y: auto; padding: 1rem; overscroll-behavior-y: contain; }
  .dialog-footer { padding-bottom: max(.85rem, env(safe-area-inset-bottom)); flex-wrap: wrap; }
  .ps-dialog .dialog-footer { flex: none; }
  .drawer-end { max-width: 100vw; }
  /* Full screen: the desktop inset pushed the 100vw drawer off the left edge. */
  .bk-drawer, .inq-drawer { --bs-drawer-inset: 0px; width: 100%; max-width: 100%; height: 100dvh; max-height: 100dvh; border: 0; border-radius: 0; }
  .bk-drawer .drawer-header, .inq-drawer .drawer-header { padding-top: max(1rem, env(safe-area-inset-top)); }
  .bk-drawer .drawer-body, .inq-drawer .drawer-body { overscroll-behavior: contain; }
  .bk-drawer .drawer-footer { padding-bottom: max(1rem, env(safe-area-inset-bottom)); }
  .bk-grid { grid-template-columns: minmax(0, 1fr); }
  .bk-grid .span-2 { grid-column: auto; }
  /* Each date keeps its time beside it, as on a wider screen. */
  .bk-stay { grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); }
  .bk-stay .span-2 { grid-column: 1 / -1; }
  /* iOS centres date and time values and collapses an empty date field. */
  input[type="date"].form-control, input[type="time"].form-control { text-align: start; }
  input.form-control::-webkit-date-and-time-value { text-align: start; min-height: 1.5em; }
  .bk-grid > *, .ps-row3 > *, .inq-form > * { min-width: 0; }
  .ps-row3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .acct-nav { scroll-padding-inline: 1rem; }
  .palette-options { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .palette-option { min-height: 3rem; padding: .7rem; overflow-wrap: anywhere; }
  .rep-actions, .inq-actions, .au-filters { flex-wrap: wrap; min-width: 0; }
  .rep-actions > *, .inq-actions > * { max-width: 100%; }
  .ws-wrap, .ws-layout, .ig-grid { min-width: 0; }
  .qf { max-width: calc(100vw - 1rem); width: calc(100vw - 1rem); max-height: calc(100dvh - 1rem); }
}

@media (width < 992px) {
  .inbox { min-width: 0; }
  .inbox[data-mobile-pane="list"] > [data-inbox-thread],
  .inbox[data-mobile-pane="thread"] > [data-inbox-list] { display: none; }
  .inbox-back { display: inline-flex; align-items: center; justify-content: center; width: 2.75rem; height: 2.75rem; flex: none; }
  [data-inbox-thread] > .card-head { position: sticky; top: 4rem; z-index: 2; background: var(--bs-bg-body); }
  [data-inbox-thread] .thread { min-height: 16rem; padding: 1rem; }
  [data-inbox-thread] .composer { padding: 1rem; }
  [data-inbox-thread] .composer-bar .btn-sm { min-height: 2.75rem; }
  .composer-hint { display: none; }
  .copilot { margin-inline: 1rem; }
  .copilot-actions { flex-wrap: wrap; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; }
}

@media (width < 768px) {
  .kpi-row { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .65rem; }
  .kpi { min-width: 0; padding: .85rem; }
  .kpi-label { font-size: .73rem; line-height: 1.4; }
  .kpi-figure { font-size: 1.5rem; }
  .kpi-delta { font-size: .7rem; line-height: 1.5; }
  .rp-property-summary > tbody > tr { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .75rem 1rem; padding: 1rem; border-bottom: 1px solid var(--cad-rule); }
  .rp-property-summary > tbody > tr > th { grid-column: 1 / -1; padding: 0; border: 0; }
  .rp-property-summary > tbody > tr > td { display: block; min-width: 0; padding: 0; border: 0; }
  .rp-property-summary > tbody > tr > td::before { display: block; float: none; width: auto; margin: 0 0 .25rem; color: var(--bs-fg-3); font-size: .68rem; font-weight: 500; }
  .rp-property-summary .cell-who { width: 100%; }
  .rp-property-summary .cell-who > span { min-width: 0; }
  .rp-property-summary .cell-who > .btn-icon { margin-left: auto; flex: none; }
  .rp-property-summary .occ { max-width: 100%; }
  body.is-keyboard-open .mobile-nav { visibility: hidden; }
}

@media (width < 992px) {
  body.inbox-thread-open { overflow: hidden; }
  .inbox[data-mobile-pane="thread"] > [data-inbox-thread] {
    position: fixed; inset: var(--topbar-height, 4rem) 0 max(calc(var(--mobile-nav-height, 0rem) + env(safe-area-inset-bottom)), var(--keyboard-inset, 0px));
    z-index: 25; display: flex; flex-direction: column; margin: 0; border: 0; border-radius: 0; overflow: hidden;
  }
  [data-inbox-thread] > .card-head { position: static; flex: none; gap: .6rem; padding: .75rem 1rem; }
  [data-inbox-thread] .inbox-back { align-self: flex-start; }
  [data-inbox-thread] > .card-head .cell-who { flex: 1; min-width: 0; }
  [data-inbox-thread] > .card-head > .d-flex { flex-basis: 100%; gap: .5rem !important; padding-left: 3.35rem; flex-wrap: wrap; }
  .inbox-message-area { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior-y: contain; background: var(--bs-bg-2); padding-bottom: 1rem; }
  [data-inbox-thread] .thread { min-height: 0; }
  [data-inbox-thread] .composer { flex: none; border-top: 1px solid var(--cad-rule); padding: .75rem 1rem; background: var(--bs-bg-body); }
  [data-inbox-thread] .composer-text { min-height: 3rem; max-height: 8rem; }
}

@media (width < 768px) {
  .rp-props > tbody > tr { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: .7rem .75rem; padding: .9rem 1rem; }
  .rp-props > tbody > tr > th { margin-bottom: .1rem; }
  .rp-props td[data-cell="Today"] { min-width: 0; }
  .rp-props td[data-cell="Next arrival"] { min-width: 0; overflow-wrap: anywhere; }
  .rp-props td[data-cell="Occupancy"] { grid-column: 1 / -1; }
  .rp-props td[data-cell="Channels"] { display: none; }
  .rp-props .occ { width: min(100%, 16rem); }
  .properties-table-foot { display: none; }
  .rp-monthly-summary > tbody > tr { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .85rem .65rem; padding: 1rem; border-bottom: 1px solid var(--cad-rule); }
  .rp-monthly-summary > tbody > tr > th { grid-column: 1 / -1; padding: 0; border: 0; }
  .rp-monthly-summary > tbody > tr > td { display: block; min-width: 0; padding: 0; border: 0; text-align: left; }
  .rp-monthly-summary > tbody > tr > td::before { display: block; float: none; width: auto; margin: 0 0 .2rem; color: var(--bs-fg-3); font-size: .68rem; font-weight: 500; }
}

@media (width < 768px) {
  [data-dashboard-properties] > .card-head { padding: 1rem; gap: 0.85rem; }
  [data-dashboard-properties] .dashboard-property-filters { display: grid; grid-template-columns: minmax(0, 1fr) auto; width: 100%; gap: 0.5rem; }
  [data-dashboard-properties] .dashboard-property-search { grid-column: 1 / -1; width: auto; }
  [data-dashboard-properties] .dashboard-property-filters label { min-width: 0; }
  [data-dashboard-properties] .dashboard-property-filters .form-control { width: 100%; min-height: 2.5rem; font-size: 0.8rem; }
  [data-dashboard-properties] .dashboard-property-filters .card-action { min-height: 2.5rem; margin: 0; padding-inline: 0.75rem; font-size: 0.75rem; }
  [data-dashboard-properties] .rp-property-summary > tbody > tr { position: relative; gap: 0.85rem 1rem; }
  [data-dashboard-properties] .rp-property-summary > tbody > tr > th { padding-right: 2.5rem; }
  [data-dashboard-properties] .rp-property-summary > tbody > tr > td.row-actions { position: absolute; top: 0.75rem; right: 0.65rem; width: auto; }
  [data-dashboard-properties] .rp-property-summary > tbody > tr > td.row-actions::before { display: none; }
  [data-dashboard-properties] .row-actions > button { min-width: 2.75rem; min-height: 2.75rem; }
  [data-dashboard-properties] .rp-property-summary .cell-who { gap: 0.65rem; }
  [data-dashboard-properties] .rp-property-summary .cell-who .sub { white-space: normal; }
  [data-dashboard-properties] .pager { padding: 0.85rem 1rem; }
}
