/* Extracted system popover/scroll containment layer from styles-layout.css. Keep this file loaded after styles-layout-filters.css. */

/* Sync health, notification + transfer center. */
.sync-health,
.notification-center {
  position: relative;
  min-width: 0;
  z-index: 1000;
}

.topbar {
  position: relative;
  z-index: 900;
}

#content {
  position: relative;
  z-index: 1;
}

.sync-health > summary,
.notification-center > summary {
  list-style: none;
}

.sync-health > summary::-webkit-details-marker,
.notification-center > summary::-webkit-details-marker {
  display: none;
}

.sync-trigger,
.notification-trigger {
  display: inline-grid !important;
  grid-auto-flow: column;
  grid-auto-columns: max-content;
  align-items: center;
  gap: 7px;
  min-height: 58px;
  border-radius: 14px;
  background: rgba(255,255,255,.82);
  cursor: pointer;
}

.sync-trigger {
  min-width: 104px;
}

.sync-trigger em {
  display: inline-grid;
  place-items: center;
  min-width: 0;
  max-width: 74px;
  padding: 3px 7px;
  border-radius: 999px;
  background: #f3e5e9;
  color: var(--brand);
  font-style: normal;
  font-size: 11px;
  font-weight: 900;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sync-health[data-sync-status="syncing"] .sync-trigger em {
  background: #fff3ca;
  color: #7a4c00;
}

.sync-health[data-sync-status="error"] .sync-trigger em {
  background: #ffe2df;
  color: #9b2f2a;
}

.sync-health[data-sync-status="ok"] .sync-trigger em {
  background: #e2f4e7;
  color: #1f6b3a;
}

.notification-trigger em {
  display: inline-grid;
  place-items: center;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--brand);
  color: #fff;
  font-style: normal;
  font-size: 12px;
  font-weight: 900;
}

.sync-popover,
.notification-popover {
  position: fixed;
  inset: calc(86px + env(safe-area-inset-top)) 24px auto auto;
  z-index: 2147483000;
  width: min(430px, calc(100vw - 32px));
  max-height: min(520px, calc(100vh - 140px));
  overflow: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  touch-action: pan-y;
  -webkit-overflow-scrolling: touch;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255,252,250,.98);
  box-shadow: var(--shadow);
}

.notification-popover {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sync-health:not([open]) .sync-popover,
.notification-center:not([open]) .notification-popover {
  display: none !important;
}

.sync-health[open] .sync-popover,
.notification-center[open] .notification-popover {
  display: block !important;
}

.notification-center[open] .notification-popover {
  display: flex !important;
}

.sync-head,
.notification-head,
.notification-item,
.notification-item > div {
  display: flex;
  align-items: center;
  gap: 8px;
}

.sync-head,
.notification-head {
  justify-content: space-between;
  padding: 4px 4px 10px;
}

.notification-head > div {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  min-width: 0;
}

.notification-filter-bar {
  display: flex;
  gap: 7px;
  max-width: 100%;
  margin: 0 0 8px;
  padding: 2px 2px 8px;
  overflow-x: auto;
  overscroll-behavior-inline: contain;
  scrollbar-gutter: stable;
  -webkit-overflow-scrolling: touch;
}

.notification-filter-btn {
  display: inline-grid;
  grid-auto-flow: column;
  align-items: center;
  gap: 5px;
  min-height: 32px;
  padding: 6px 10px;
  border: 1px solid #eadbdd;
  border-radius: 999px;
  background: #fff;
  color: var(--muted);
  font: inherit;
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
  cursor: pointer;
}

.notification-filter-btn em {
  display: inline-grid;
  place-items: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: #f3e5e9;
  color: var(--brand);
  font-style: normal;
  font-size: 10.5px;
  font-weight: 950;
}

.notification-filter-btn.is-active {
  border-color: rgba(157, 74, 96, .45);
  background: var(--brand);
  color: #fff;
}

.notification-filter-btn.is-active em {
  background: rgba(255,255,255,.24);
  color: #fff;
}

.notification-list-meta {
  margin: 0 4px 8px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 850;
  flex: 0 0 auto;
}

.notification-list {
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
}

/* System scroll containment: floating layers can scroll internally, but wheel/touch
   events must not bubble into the page behind them at top/bottom edges. */
.modal-backdrop,
.modal-card,
.store-db-edit-modal,
.shared-store-item-modal,
.photo-preview-dialog,
.qr-preview-card,
.range-calendar-panel,
.cs-multi-panel,
.record-multi-panel,
.task-multi-panel,
.audit-multi-panel,
.record-bulk-popover,
.task-filter-panel,
.sync-popover,
.notification-popover,
.notification-list,
.staff-branch-panel,
.record-detail-list.is-resizable-detail,
.record-detail-list .detail-item.is-long-detail > dd,
.payment-approval-main.is-resizable-detail,
.payment-approval-main .detail-item.is-long-detail > dd,
.task-view-details:has(.is-resizable-detail),
.task-detail-items,
.task-payment-rows,
.audit-detail-grid,
.ordering-detail-grid,
.storage-monitor-detail-grid,
.photo-storage-grid {
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  -webkit-overflow-scrolling: touch;
}

.record-bulk-popover,
.task-filter-panel {
  max-height: min(320px, calc(100vh - 140px));
  overflow: auto;
}

.sync-facts {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin: 0;
}

.sync-facts div,
.sync-health-error {
  min-width: 0;
  padding: 9px;
  border: 1px solid #eadbdd;
  border-radius: 12px;
  background: #fff;
}

.sync-facts dt,
.sync-health-error b {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 10.5px;
  font-weight: 950;
  text-transform: none;
  letter-spacing: 0;
}

.sync-facts dd,
.sync-health-error span,
.sync-health-error time {
  display: block;
  min-width: 0;
  margin: 0;
  overflow-wrap: anywhere;
  color: var(--ink);
  font-size: 13px;
  font-weight: 850;
}

.sync-health-error {
  margin-top: 8px;
  border-color: #f0b8b2;
  background: #fff8f7;
}

.sync-health-error time {
  margin-top: 4px;
  color: var(--muted);
  font-size: 11px;
}

.notification-item {
  justify-content: space-between;
  padding: 10px;
  border: 1px solid #eadbdd;
  border-radius: 12px;
  background: #fff;
}

.notification-item + .notification-item {
  margin-top: 8px;
}

.notification-item.is-unread {
  border-color: rgba(157, 74, 96, .45);
  box-shadow: inset 4px 0 0 var(--brand);
}

.notification-item > button {
  display: grid;
  gap: 3px;
  min-width: 0;
  border: 0;
  background: transparent;
  color: inherit;
  text-align: left;
  cursor: pointer;
}

.notification-item b,
.notification-item span,
.notification-item time {
  min-width: 0;
  overflow-wrap: anywhere;
}

.notification-item span,
.notification-item time,
.notification-empty {
  color: var(--muted);
}

.notification-item time {
  font-size: 12px;
}

.notification-empty {
  padding: 18px 10px;
  text-align: center;
}

.record-transfer-status {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 5px 9px;
  border-radius: 999px;
  background: #f5dfe8;
  color: var(--brand);
  font-size: 12px;
  font-weight: 900;
  vertical-align: middle;
}

:is(.record-list-card, .deleted-records-card) .record-action-cell {
  min-width: 0;
  white-space: normal !important;
}

:is(.record-list-card, .deleted-records-card) .record-action-cell .record-icon-action,
:is(.record-list-card, .deleted-records-card) .record-action-cell .record-transfer-status-icon,
body.mobile-layout-mode :is(.record-list-card, .deleted-records-card) .record-action-cell .record-icon-action,
body.mobile-layout-mode :is(.record-list-card, .deleted-records-card) .record-action-cell .record-transfer-status-icon,
body.mobile-preview-mode :is(.record-list-card, .deleted-records-card) .record-action-cell .record-icon-action,
body.mobile-preview-mode :is(.record-list-card, .deleted-records-card) .record-action-cell .record-transfer-status-icon {
  width: 34px !important;
  min-width: 34px !important;
  max-width: 34px !important;
  min-height: 34px !important;
  padding: 0 !important;
  margin: 2px !important;
  justify-self: start !important;
}

body.mobile-layout-mode :is(.record-list-card, .deleted-records-card) .record-action-cell,
body.mobile-preview-mode :is(.record-list-card, .deleted-records-card) .record-action-cell {
  grid-template-columns: repeat(4, 34px) minmax(0, 1fr) !important;
  align-items: center !important;
  gap: 5px !important;
}

.record-policy-hint {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  max-width: 100%;
  padding: 5px 9px;
  border-radius: 999px;
  background: #fff3ca;
  color: #7a4c00;
  font-size: 12px;
  font-weight: 900;
  vertical-align: middle;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.record-bulk-toolbar:not([open]) .record-bulk-popover {
  display: none !important;
}

.record-bulk-toolbar[open] .record-bulk-popover {
  display: grid !important;
  z-index: 1200;
}

.task-card.is-jump-highlight,
.cs-heatmap-detail-outside:focus {
  animation: record-jump-highlight 1.8s ease;
  outline: 0;
}

@media (max-width: 760px) {
  .topbar-actions {
    grid-template-columns: minmax(0, 1fr) 44px 44px 44px 64px !important;
  }

  .topbar-actions .admin-switcher {
    grid-column: 1 / -1;
  }

  .sync-trigger {
    width: 100%;
    min-width: 0;
    min-height: 42px;
    padding-inline: 8px;
    grid-auto-columns: max-content;
    justify-content: center;
  }

  .sync-trigger b {
    display: none;
  }

  .sync-trigger em {
    max-width: 58px;
    padding-inline: 5px;
    font-size: 9.5px;
  }

  .sync-popover {
    position: fixed;
    inset: calc(72px + env(safe-area-inset-top)) 10px auto 10px;
    width: auto;
    max-height: calc(100dvh - 170px - env(safe-area-inset-bottom));
  }

  .sync-facts {
    grid-template-columns: 1fr;
  }

  .notification-trigger {
    width: 44px;
    min-height: 42px;
    padding-inline: 0;
    place-content: center;
  }

  .notification-trigger b {
    display: none;
  }

  .notification-trigger em {
    position: absolute;
    top: -4px;
    right: -4px;
  }

  .notification-popover {
    position: fixed;
    top: calc(72px + env(safe-area-inset-top));
    left: 10px;
    right: 10px;
    width: auto;
    max-height: calc(100dvh - 170px - env(safe-area-inset-bottom));
  }

  .notification-filter-bar {
    margin-inline: -2px;
    padding-bottom: 7px;
  }

  .notification-filter-btn {
    min-height: 30px;
    padding: 5px 9px;
    font-size: 11px;
  }

  .notification-item {
    align-items: stretch;
    flex-direction: column;
  }

  .notification-item > div {
    justify-content: flex-end;
    flex-wrap: wrap;
  }
}

body.mobile-preview-mode .topbar-actions,
body.mobile-layout-mode .topbar-actions {
  grid-template-columns: minmax(0, 1fr) 44px 44px 44px 64px !important;
}

body.mobile-preview-mode .sync-trigger,
body.mobile-layout-mode .sync-trigger {
  width: 100%;
  min-width: 0;
  min-height: 42px;
  padding-inline: 8px;
  justify-content: center;
}

body.mobile-preview-mode .sync-trigger b,
body.mobile-layout-mode .sync-trigger b {
  display: none;
}

body.mobile-preview-mode .sync-trigger em,
body.mobile-layout-mode .sync-trigger em {
  max-width: 58px;
  padding-inline: 5px;
  font-size: 9.5px;
}

body.mobile-preview-mode .notification-trigger,
body.mobile-layout-mode .notification-trigger {
  width: 44px;
  min-height: 42px;
  padding-inline: 0;
  place-content: center;
}

body.mobile-preview-mode .notification-trigger b,
body.mobile-layout-mode .notification-trigger b {
  display: none;
}

body.mobile-preview-mode .notification-popover,
body.mobile-layout-mode .notification-popover {
  position: fixed;
  top: calc(72px + env(safe-area-inset-top));
  left: 10px;
  right: 10px;
  width: auto;
  max-height: calc(100dvh - 170px - env(safe-area-inset-bottom));
}

body.mobile-preview-mode .notification-filter-bar,
body.mobile-layout-mode .notification-filter-bar {
  margin-inline: -2px;
  padding-bottom: 7px;
}

body.mobile-preview-mode .notification-filter-btn,
body.mobile-layout-mode .notification-filter-btn {
  min-height: 30px;
  padding: 5px 9px;
  font-size: 11px;
}

body.mobile-preview-mode .sync-popover,
body.mobile-layout-mode .sync-popover {
  position: fixed;
  inset: calc(72px + env(safe-area-inset-top)) 10px auto 10px;
  width: auto;
  max-height: calc(100dvh - 170px - env(safe-area-inset-bottom));
}
