/* Organization mobile shell — isolated PWA/mobile foundation (Phase 1) */
/* All rules are scoped via body.organization-mobile-context or .organization-mobile-* */
/* No global element overrides without scope */

.organization-mobile-bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 50;
  display: none;
  align-items: stretch;
  justify-content: space-around;
  gap: 2px;
  height: calc(64px + env(safe-area-inset-bottom, 0px));
  padding: 6px 4px calc(6px + env(safe-area-inset-bottom, 0px));
  background: #ffffff;
  border-top: 1px solid #e5e7eb;
  box-sizing: border-box;
}

/* Desktop: explicitly hidden */
@media (min-width: 768px) {
  .organization-mobile-bottom-nav {
    display: none !important;
  }
}

/* Mobile: only visible when body has organization context */
@media (max-width: 767px) {
  body.organization-mobile-context .organization-mobile-bottom-nav {
    display: flex;
  }

  /* Prevent content from being hidden under fixed nav */
  body.organization-mobile-context #root {
    padding-bottom: calc(68px + env(safe-area-inset-bottom, 0px));
  }

  /* Fallback if #root is not the scroll container: also ensure .content has clearance */
  body.organization-mobile-context .content {
    padding-bottom: calc(8px + env(safe-area-inset-bottom, 0px));
  }
}

.organization-mobile-bottom-nav .organization-mobile-nav-item {
  flex: 1 1 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-width: 44px;
  min-height: 44px;
  padding: 4px 6px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: #667085;
  font-size: 11px;
  font-weight: 500;
  line-height: 1;
  letter-spacing: -0.01em;
  text-decoration: none;
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  transition: color 0.15s ease, background-color 0.15s ease;
}

.organization-mobile-bottom-nav .organization-mobile-nav-item svg {
  width: 22px;
  height: 22px;
  flex: 0 0 22px;
  display: block;
  stroke-width: 1.9;
}

.organization-mobile-bottom-nav .organization-mobile-nav-item span {
  display: block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  line-height: 1;
}

.organization-mobile-bottom-nav .organization-mobile-nav-item.active {
  color: #4299e1;
}

.organization-mobile-bottom-nav .organization-mobile-nav-item:active {
  background: #f2f4f7;
}

.organization-mobile-bottom-nav .organization-mobile-nav-item:focus-visible {
  outline: 2px solid #9cc3ff;
  outline-offset: 2px;
  background: #eef5ff;
}

/* ===== Phase 2: Mobile top bar & More bottom sheet ===== */

.organization-mobile-topbar {
  display: none;
}

@media (min-width: 768px) {
  .organization-mobile-topbar,
  .organization-mobile-more-backdrop,
  .organization-mobile-more-sheet {
    display: none !important;
  }
}

@media (max-width: 767px) {
  body.organization-mobile-context .organization-mobile-topbar {
    display: flex;
    position: sticky;
    top: 0;
    z-index: 55;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    min-height: calc(60px + env(safe-area-inset-top, 0px));
    padding: env(safe-area-inset-top, 0px) 14px 10px;
    background: #ffffff;
    border-bottom: 1px solid #e5e7eb;
    box-sizing: border-box;
  }

  body.organization-mobile-context .organization-mobile-topbar-main {
    display: grid;
    gap: 2px;
    min-width: 0;
    flex: 1 1 auto;
  }

  body.organization-mobile-context .organization-mobile-topbar-org {
    margin: 0;
    color: #667085;
    font-size: 12px;
    font-weight: 500;
    line-height: 1.2;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  body.organization-mobile-context .organization-mobile-topbar-title {
    margin: 0;
    color: #101828;
    font-size: 17px;
    font-weight: 600;
    line-height: 1.2;
    letter-spacing: -0.01em;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  body.organization-mobile-context .organization-mobile-topbar-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 0 0 auto;
  }

  body.organization-mobile-context .organization-mobile-topbar-more {
    display: inline-grid;
    place-items: center;
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
    padding: 0;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    background: #fff;
    color: #344054;
  }

  body.organization-mobile-context .organization-mobile-topbar-more svg {
    width: 20px;
    height: 20px;
  }

  /* Hide desktop UI on mobile organization context */
  body.organization-mobile-context .sidebar,
  body.organization-mobile-context .topbar {
    display: none !important;
  }

  body.organization-mobile-context .content {
    margin-left: 0 !important;
    padding: 16px;
  }

  body.organization-mobile-context .app.sidebar-open .content {
    margin-left: 0 !important;
  }

  /* Scroll lock when sheet open - only mobile org context */
  body.organization-mobile-context.organization-mobile-sheet-open {
    overflow: hidden;
  }

  body.organization-mobile-context .organization-mobile-more-backdrop {
    position: fixed;
    inset: 0;
    z-index: 60;
    background: rgb(15 23 42 / 38%);
    backdrop-filter: blur(2px);
    opacity: 0;
    transition: opacity 0.22s ease;
  }

  body.organization-mobile-context .organization-mobile-more-backdrop.is-open {
    opacity: 1;
  }

  body.organization-mobile-context .organization-mobile-more-sheet {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 61;
    display: block;
    max-height: min(82vh, calc(100dvh - 24px));
    padding-bottom: env(safe-area-inset-bottom, 0px);
    background: #fff;
    border-top-left-radius: 16px;
    border-top-right-radius: 16px;
    box-shadow: 0 -12px 40px rgb(15 23 42 / 18%);
    transform: translateY(100%);
    opacity: 0;
    transition: transform 0.26s ease, opacity 0.22s ease;
    overflow: hidden;
    box-sizing: border-box;
  }

  body.organization-mobile-context .organization-mobile-more-sheet.is-open {
    transform: translateY(0);
    opacity: 1;
  }

  body.organization-mobile-context .organization-mobile-more-sheet[hidden],
  body.organization-mobile-context .organization-mobile-more-backdrop[hidden] {
    display: none !important;
  }
}

/* Sheet inner layout - always scoped but base styles outside media for simplicity */
.organization-mobile-sheet-head {
  display: grid;
  gap: 8px;
  padding: 10px 16px 12px;
  border-bottom: 1px solid #eef2f7;
  position: sticky;
  top: 0;
  background: #fff;
  z-index: 1;
}

.organization-mobile-sheet-drag {
  width: 36px;
  height: 4px;
  border-radius: 999px;
  background: #d0d5dd;
  justify-self: center;
}

.organization-mobile-sheet-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.organization-mobile-sheet-title-row h2 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: -0.01em;
  color: #101828;
}

.organization-mobile-sheet-close {
  display: inline-grid;
  place-items: center;
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  padding: 0;
  border: 0;
  border-radius: 10px;
  background: #f2f4f7;
  color: #344054;
  font-size: 22px;
  line-height: 1;
}

.organization-mobile-sheet-body {
  display: grid;
  gap: 16px;
  padding: 16px;
  max-height: calc(min(82vh, 100dvh - 24px) - 64px);
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
}

.organization-mobile-sheet-org {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  background: #f9fafb;
}

.organization-mobile-sheet-org label {
  display: grid;
  gap: 6px;
  color: #344054;
  font-size: 13px;
  font-weight: 500;
}

.organization-mobile-sheet-org select {
  width: 100%;
  min-height: 44px;
  border: 1px solid #d0d5dd;
  border-radius: 8px;
  padding: 8px 10px;
  background: #fff;
  color: #101828;
  font-size: 14px;
}

.organization-mobile-sheet-section {
  display: grid;
  gap: 8px;
}

.organization-mobile-sheet-section-title {
  margin: 0;
  color: #98a2b3;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.organization-mobile-sheet-nav {
  display: grid;
  gap: 8px;
}

.organization-mobile-sheet-link,
.organization-mobile-sheet-logout-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 48px;
  padding: 10px 12px;
  border: 1px solid #eef2f7;
  border-radius: 12px;
  background: #fff;
  color: #101828;
  font-size: 14px;
  font-weight: 500;
  line-height: 1.3;
  text-decoration: none;
  text-align: left;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}

.organization-mobile-sheet-link.active {
  background: #eef6ff;
  border-color: #bfdbfe;
  color: #1d4ed8;
}

.organization-mobile-sheet-link:active,
.organization-mobile-sheet-logout-btn:active {
  background: #f2f4f7;
}

.organization-mobile-sheet-icon {
  width: 20px;
  height: 20px;
  flex: 0 0 20px;
  opacity: 0.95;
}

.organization-mobile-sheet-logout-btn {
  width: 100%;
  justify-content: center;
  background: #fff;
  border-color: #fecaca;
  color: #b42318;
}

@media (min-width: 768px) {
  .organization-mobile-sheet-head,
  .organization-mobile-sheet-body,
  .organization-mobile-sheet-section,
  .organization-mobile-sheet-nav {
    display: none !important;
  }
}

/* ===== Phase 4: Mobile booking agenda ===== */

.booking-mobile-agenda,
.booking-mobile-controls,
.booking-mobile-online,
.booking-mobile-filters {
  display: none;
}

@media (min-width: 768px) {
  .booking-mobile-agenda,
  .booking-mobile-controls {
    display: none !important;
  }
}

@media (max-width: 767px) {
  body.organization-mobile-context .booking-mobile-agenda {
    display: grid;
    gap: 14px;
  }

  body.organization-mobile-context .booking-mobile-controls {
    display: grid;
    gap: 12px;
    margin-bottom: 16px;
  }

  body.organization-mobile-context .booking-mobile-controls-row {
    display: grid;
    grid-template-columns: 44px 1fr 44px 44px;
    gap: 8px;
    align-items: center;
  }

  body.organization-mobile-context .booking-mobile-nav-btn {
    display: inline-grid;
    place-items: center;
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
    padding: 0;
    border: 1px solid #d0d5dd;
    border-radius: 10px;
    background: #fff;
    color: #344054;
    font-size: 18px;
    font-weight: 600;
  }

  body.organization-mobile-context .booking-mobile-range {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    padding: 8px 12px;
    border: 1px solid #d0d5dd;
    border-radius: 10px;
    background: #fff;
    color: #101828;
    font-size: 14px;
    font-weight: 600;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  body.organization-mobile-context .booking-mobile-create {
    display: inline-grid;
    place-items: center;
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
    padding: 0;
    border-radius: 10px;
    background: #4299e1;
    color: #fff;
    font-size: 22px;
    font-weight: 600;
    line-height: 1;
  }

  body.organization-mobile-context .booking-mobile-primary {
    width: 100%;
    min-height: 44px;
    border-radius: 10px;
    background: #4299e1;
    color: #fff;
    font-weight: 600;
  }

  body.organization-mobile-context .booking-mobile-online {
    display: grid;
    gap: 8px;
    padding: 12px;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    background: #f9fafb;
  }

  body.organization-mobile-context .booking-mobile-online > span {
    color: #667085;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.02em;
    text-transform: uppercase;
  }

  body.organization-mobile-context .booking-mobile-online-actions {
    display: flex;
    gap: 8px;
  }

  body.organization-mobile-context .booking-mobile-online-actions a,
  body.organization-mobile-context .booking-mobile-online-actions button {
    flex: 1 1 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
  }

  body.organization-mobile-context .booking-mobile-online-actions a {
    border: 1px solid #d0d5dd;
    background: #fff;
    color: #344054;
  }

  body.organization-mobile-context .booking-mobile-filters {
    display: grid;
    gap: 8px;
  }

  body.organization-mobile-context .booking-mobile-filters-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    min-height: 44px;
    padding: 10px 12px;
    border: 1px solid #d0d5dd;
    border-radius: 10px;
    background: #fff;
    color: #344054;
    font-size: 14px;
    font-weight: 500;
    text-align: left;
  }

  body.organization-mobile-context .booking-mobile-filters-panel {
    display: grid;
    gap: 10px;
    padding: 12px;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    background: #f9fafb;
  }

  body.organization-mobile-context .booking-mobile-filters-panel[hidden] {
    display: none !important;
  }

  body.organization-mobile-context .booking-mobile-filters-panel label {
    display: grid;
    gap: 6px;
    color: #344054;
    font-size: 13px;
    font-weight: 500;
  }

  body.organization-mobile-context .booking-mobile-filters-panel select,
  body.organization-mobile-context .booking-mobile-filters-panel input {
    min-height: 44px;
  }

  body.organization-mobile-context .booking-mobile-slot-settings {
    display: grid;
    gap: 8px;
    padding: 10px;
    border: 1px dashed #d0d5dd;
    border-radius: 8px;
    background: #fff;
  }

  body.organization-mobile-context .booking-mobile-slot-settings strong {
    font-size: 12px;
  }

  body.organization-mobile-context .booking-mobile-day {
    display: grid;
    gap: 10px;
    padding: 12px;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    background: #fff;
  }

  body.organization-mobile-context .booking-mobile-day.is-today {
    border-color: #bfdbfe;
    background: #f8fbff;
  }

  body.organization-mobile-context .booking-mobile-day-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid #eef2f7;
  }

  body.organization-mobile-context .booking-mobile-day-title {
    display: grid;
    gap: 2px;
  }

  body.organization-mobile-context .booking-mobile-day-weekday {
    color: #101828;
    font-size: 15px;
    font-weight: 600;
    line-height: 1.2;
  }

  body.organization-mobile-context .booking-mobile-day-date {
    color: #667085;
    font-size: 13px;
  }

  body.organization-mobile-context .booking-mobile-day-count {
    color: #667085;
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
  }

  body.organization-mobile-context .booking-mobile-day-events {
    display: grid;
    gap: 10px;
  }

  body.organization-mobile-context .booking-mobile-event {
    display: grid;
    gap: 6px;
    width: 100%;
    padding: 12px;
    border: 1px solid #eef2f7;
    border-radius: 12px;
    background: #fff;
    text-align: left;
    cursor: pointer;
    transition: border-color 0.15s ease, background-color 0.15s ease;
  }

  body.organization-mobile-context .booking-mobile-event:active {
    background: #f9fafb;
  }

  body.organization-mobile-context .booking-mobile-event-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
  }

  body.organization-mobile-context .booking-mobile-event-time {
    color: #101828;
    font-size: 13px;
    font-weight: 600;
  }

  body.organization-mobile-context .booking-mobile-event-status {
    padding: 3px 8px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
    line-height: 1;
    white-space: nowrap;
  }

  body.organization-mobile-context .booking-mobile-status-scheduled .booking-mobile-event-status {
    background: #eef6ff;
    color: #1d4ed8;
  }

  body.organization-mobile-context .booking-mobile-status-completed .booking-mobile-event-status {
    background: #ecfdf3;
    color: #067647;
  }

  body.organization-mobile-context .booking-mobile-status-cancelled .booking-mobile-event-status {
    background: #fef3f2;
    color: #b42318;
  }

  body.organization-mobile-context .booking-mobile-status-no_show .booking-mobile-event-status {
    background: #fffaeb;
    color: #b54708;
  }

  body.organization-mobile-context .booking-mobile-event-client {
    color: #101828;
    font-size: 15px;
    font-weight: 600;
    line-height: 1.3;
  }

  body.organization-mobile-context .booking-mobile-event-service {
    color: #344054;
    font-size: 13px;
  }

  body.organization-mobile-context .booking-mobile-event-meta,
  body.organization-mobile-context .booking-mobile-event-phone {
    color: #667085;
    font-size: 12px;
  }

  body.organization-mobile-context .booking-mobile-empty {
    display: grid;
    gap: 10px;
    padding: 16px;
    border: 1px dashed #d0d5dd;
    border-radius: 12px;
    background: #fafcff;
    text-align: center;
  }

  body.organization-mobile-context .booking-mobile-empty p {
    margin: 0;
    color: #667085;
    font-size: 14px;
  }

  body.organization-mobile-context .booking-mobile-empty .primary {
    width: 100%;
    min-height: 44px;
  }

  /* Hide desktop calendar and toolbar on mobile organization context */
  body.organization-mobile-context .booking-page > .booking-toolbar {
    display: none !important;
  }

  body.organization-mobile-context .booking-calendar-viewport {
    display: none !important;
  }

  body.organization-mobile-context .booking-add-row {
    display: none !important;
  }

  body.organization-mobile-context .booking-toolbar .booking-filters {
    display: none !important;
  }

  body.organization-mobile-context .booking-toolbar .booking-slot-settings {
    display: none !important;
  }

  body.organization-mobile-context .booking-online-link {
    display: none !important;
  }

  /* Ensure booking page itself fits viewport without horizontal scroll */
  body.organization-mobile-context .booking-page {
    min-width: 0;
    max-width: 100%;
    overflow-x: hidden;
  }

  body.organization-mobile-context .booking-toolbar {
    gap: 0;
  }

  /* Date picker full width on mobile */
  body.organization-mobile-context [data-booking-date-picker] {
    left: 0 !important;
    right: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box;
  }

  body.organization-mobile-context [data-booking-date-picker] .booking-picker-day,
  body.organization-mobile-context [data-booking-date-picker] button {
    min-height: 44px;
  }

  /* Modals adapted for mobile - only booking modals scoped */
  body.organization-mobile-context [data-booking-create-modal] .modal-card,
  body.organization-mobile-context [data-booking-visit-modal] .modal-card {
    width: min(720px, calc(100vw - 16px));
    max-height: calc(100dvh - 16px);
    overflow-y: auto;
  }

  body.organization-mobile-context [data-booking-create-modal] .modal-grid,
  body.organization-mobile-context [data-booking-visit-modal] .modal-grid {
    grid-template-columns: 1fr;
  }

  body.organization-mobile-context [data-booking-create-modal] .booking-create-slots-list label span,
  body.organization-mobile-context [data-booking-visit-modal] input,
  body.organization-mobile-context [data-booking-visit-modal] select {
    min-height: 44px;
  }
}

/* ===== Phase 5: Mobile clients list ===== */

.client-mobile-list,
.client-mobile-sort,
.client-mobile-empty,
.client-mobile-create-toggle {
  display: none;
}

@media (min-width: 768px) {
  .client-mobile-list,
  .client-mobile-sort,
  .client-mobile-empty,
  .client-mobile-create-toggle {
    display: none !important;
  }
  .client-mobile-create-panel {
    display: block !important;
  }
  .client-mobile-create-panel[hidden] {
    display: block !important;
  }
}

@media (max-width: 767px) {
  body.organization-mobile-context .centered-list-table.app-table {
    display: none !important;
  }

  body.organization-mobile-context .client-mobile-sort {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 10px;
    margin: 12px 0;
  }

  body.organization-mobile-context .client-mobile-sort label {
    display: grid;
    gap: 6px;
    color: #344054;
    font-size: 13px;
    font-weight: 500;
  }

  body.organization-mobile-context .client-mobile-sort select {
    min-height: 44px;
  }

  body.organization-mobile-context .client-mobile-list {
    display: grid;
    gap: 10px;
    margin-bottom: 14px;
  }

  body.organization-mobile-context .client-mobile-card {
    display: grid;
    gap: 6px;
    width: 100%;
    padding: 12px;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    background: #fff;
    text-align: left;
    cursor: pointer;
  }

  body.organization-mobile-context .client-mobile-card:active {
    background: #f9fafb;
  }

  body.organization-mobile-context .client-mobile-card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
  }

  body.organization-mobile-context .client-mobile-card-name {
    color: #101828;
    font-size: 15px;
    font-weight: 600;
    line-height: 1.3;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  body.organization-mobile-context .client-mobile-card-status {
    flex: 0 0 auto;
    padding: 3px 8px;
    border-radius: 999px;
    background: #f2f4f7;
    color: #667085;
    font-size: 11px;
    font-weight: 600;
    white-space: nowrap;
  }

  body.organization-mobile-context .client-mobile-card-status.is-active {
    background: #ecfdf3;
    color: #067647;
  }

  body.organization-mobile-context .client-mobile-card-status.is-archived {
    background: #fef3f2;
    color: #b42318;
  }

  body.organization-mobile-context .client-mobile-card-phone {
    color: #344054;
    font-size: 13px;
    font-weight: 500;
  }

  body.organization-mobile-context .client-mobile-card-meta {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    color: #667085;
    font-size: 12px;
  }

  body.organization-mobile-context .client-mobile-empty {
    display: grid;
    gap: 10px;
    padding: 20px;
    border: 1px dashed #d0d5dd;
    border-radius: 12px;
    background: #fafcff;
    text-align: center;
    color: #667085;
  }

  body.organization-mobile-context .client-mobile-create-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-height: 44px;
    margin-bottom: 12px;
    border-radius: 10px;
    background: #4299e1;
    color: #fff;
    font-weight: 600;
  }

  body.organization-mobile-context .client-mobile-create-panel {
    display: grid;
    gap: 12px;
    margin-bottom: 16px;
  }

  body.organization-mobile-context .client-mobile-create-panel[hidden] {
    display: none !important;
  }

  body.organization-mobile-context [data-client-create].inline-form {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
  }

  body.organization-mobile-context [data-client-create].inline-form label,
  body.organization-mobile-context [data-client-create].inline-form input,
  body.organization-mobile-context [data-client-create].inline-form select {
    width: 100%;
    min-height: 44px;
  }

  body.organization-mobile-context [data-client-create].inline-form button.primary {
    width: 100%;
    min-height: 44px;
  }

  body.organization-mobile-context .client-search {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 8px;
    align-items: end;
  }

  body.organization-mobile-context .client-search label {
    min-width: 0;
  }

  body.organization-mobile-context .client-search input {
    min-height: 44px;
  }

  body.organization-mobile-context .client-search .primary,
  body.organization-mobile-context .client-search .client-search-reset {
    min-height: 44px;
    white-space: nowrap;
  }

  body.organization-mobile-context [data-clients] .pagination {
    display: grid;
    gap: 10px;
  }

  body.organization-mobile-context [data-clients] .pagination > div {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: end;
  }

  body.organization-mobile-context [data-clients] .pagination select,
  body.organization-mobile-context [data-clients] .pagination button {
    min-height: 44px;
  }

  /* Ensure no horizontal scroll for clients */
  body.organization-mobile-context [data-clients] {
    min-width: 0;
    max-width: 100%;
    overflow-x: hidden;
  }

  /* Registration link block compact on mobile - scoped to clients only */
  body.organization-mobile-context [data-clients] .subpanel {
    padding: 14px;
  }

  body.organization-mobile-context [data-clients] .subpanel .inline-form {
    grid-template-columns: 1fr;
  }
}

/* ===== Phase 6: Mobile client details ===== */

@media (min-width: 768px) {
  .client-mobile-section-toggle {
    display: none !important;
  }
  .client-mobile-section-content {
    display: block !important;
  }
  .client-mobile-section-content[hidden] {
    display: block !important;
  }
}

@media (max-width: 767px) {
  body.organization-mobile-context [data-client-modal] {
    align-items: flex-start;
    padding: env(safe-area-inset-top, 0px) 0 env(safe-area-inset-bottom, 0px);
    overflow-y: auto;
  }

  body.organization-mobile-context [data-client-modal] .modal-card.client-profile-modal {
    width: min(720px, calc(100vw - 12px));
    max-width: calc(100vw - 12px);
    max-height: calc(100dvh - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px) - 12px);
    margin: 6px auto;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border-radius: 16px;
  }

  body.organization-mobile-context [data-client-modal] .modal-head {
    position: sticky;
    top: 0;
    z-index: 2;
    background: #fff;
    border-bottom: 1px solid #eef2f7;
    padding-top: env(safe-area-inset-top, 0px);
  }

  body.organization-mobile-context [data-client-modal] .modal-head h3 {
    font-size: 17px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  body.organization-mobile-context [data-client-modal] .modal-head .modal-close-icon {
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
  }

  body.organization-mobile-context [data-client-modal] .client-profile-card-head {
    padding: 12px 16px;
    gap: 12px;
  }

  body.organization-mobile-context [data-client-modal] .client-profile-card-head h4 {
    font-size: 18px;
  }

  body.organization-mobile-context [data-client-modal] .client-profile-modal {
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
  }

  body.organization-mobile-context .client-mobile-section {
    display: grid;
    gap: 0;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    background: #fff;
    overflow: hidden;
  }

  body.organization-mobile-context .client-mobile-section-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    min-height: 48px;
    padding: 12px 14px;
    border: 0;
    background: #f9fafb;
    color: #101828;
    font-size: 15px;
    font-weight: 600;
    text-align: left;
    cursor: pointer;
  }

  body.organization-mobile-context .client-mobile-section-toggle[aria-expanded="true"] {
    background: #eef6ff;
    color: #1d4ed8;
  }

  body.organization-mobile-context .client-mobile-section-chevron {
    width: 10px;
    height: 10px;
    border-right: 2px solid currentColor;
    border-bottom: 2px solid currentColor;
    transform: rotate(-45deg);
    transition: transform 0.18s ease;
    flex: 0 0 auto;
  }

  body.organization-mobile-context .client-mobile-section-toggle[aria-expanded="true"] .client-mobile-section-chevron {
    transform: rotate(45deg);
  }

  body.organization-mobile-context .client-mobile-section-content {
    display: grid;
    gap: 12px;
    padding: 14px;
  }

  body.organization-mobile-context .client-mobile-section-content[hidden] {
    display: none !important;
  }

  body.organization-mobile-context [data-client-modal] .modal-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  body.organization-mobile-context [data-client-modal] .modal-grid label,
  body.organization-mobile-context [data-client-modal] .modal-grid input,
  body.organization-mobile-context [data-client-modal] .modal-grid select,
  body.organization-mobile-context [data-client-modal] .modal-grid textarea {
    width: 100%;
    min-height: 44px;
  }

  body.organization-mobile-context [data-client-modal] .modal-grid button.primary,
  body.organization-mobile-context [data-client-modal] .modal-grid .primary,
  body.organization-mobile-context [data-client-modal] .subpanel button.primary {
    min-height: 44px;
    width: 100%;
  }

  body.organization-mobile-context [data-client-modal] .subpanel {
    padding: 14px;
  }

  body.organization-mobile-context [data-client-modal] .subpanel .inline-form {
    grid-template-columns: 1fr;
  }

  body.organization-mobile-context [data-client-modal] .app-table {
    display: block;
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  body.organization-mobile-context [data-client-modal] .app-table table {
    min-width: 520px;
  }

  body.organization-mobile-context [data-client-modal] .visit-photo-album {
    gap: 10px;
  }

  body.organization-mobile-context [data-client-modal] .service-image-previews {
    grid-template-columns: repeat(auto-fill, minmax(86px, 1fr));
  }

  body.organization-mobile-context [data-client-modal] .client-referral-link-block input,
  body.organization-mobile-context [data-client-modal] input[data-generated-auth-link] {
    width: 100%;
    overflow-wrap: anywhere;
  }

  body.organization-mobile-context [data-client-modal] .inline-form.compact {
    grid-template-columns: 1fr;
  }

  body.organization-mobile-context [data-client-modal] .inline-form.compact a,
  body.organization-mobile-context [data-client-modal] .inline-form.compact input {
    overflow-wrap: anywhere;
    word-break: break-all;
  }

  body.organization-mobile-context [data-client-modal] .modal-card {
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }

  /* Ensure bottom nav does not overlap modal */
  body.organization-mobile-context [data-client-modal] {
    z-index: 70;
  }

  body.organization-mobile-context .client-confirm-card {
    width: min(360px, calc(100vw - 24px)) !important;
  }
}

/* ===== Phase 7: Mobile dashboard ===== */

.organization-mobile-dashboard {
  display: none;
}

@media (min-width: 768px) {
  .organization-mobile-dashboard {
    display: none !important;
  }
}

@media (max-width: 767px) {
  body.organization-mobile-context .dashboard-desktop-grid {
    display: none !important;
  }

  body.organization-mobile-context .organization-mobile-dashboard {
    display: grid;
    gap: 16px;
  }

  body.organization-mobile-context .organization-mobile-dashboard-summary {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
  }

  body.organization-mobile-context .organization-mobile-dashboard-card {
    display: grid;
    gap: 6px;
    min-height: 88px;
    padding: 14px 16px;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    background: #fff;
  }

  body.organization-mobile-context .organization-mobile-dashboard-card span {
    color: #667085;
    font-size: 13px;
    font-weight: 500;
  }

  body.organization-mobile-context .organization-mobile-dashboard-card strong {
    color: #101828;
    font-size: 22px;
    font-weight: 600;
    line-height: 1.2;
  }

  body.organization-mobile-context .organization-mobile-dashboard-card--full {
    grid-column: 1 / -1;
  }

  body.organization-mobile-context .organization-mobile-dashboard-actions {
    display: grid;
    gap: 12px;
    padding: 14px;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    background: #fff;
  }

  body.organization-mobile-context .organization-mobile-dashboard-actions h3 {
    margin: 0;
    color: #101828;
    font-size: 15px;
    font-weight: 600;
  }

  body.organization-mobile-context .organization-mobile-dashboard-actions-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }

  body.organization-mobile-context .organization-mobile-dashboard-action {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 72px;
    padding: 12px;
    border: 1px solid #eef2f7;
    border-radius: 12px;
    background: #f9fafb;
    color: #101828;
    font-size: 13px;
    font-weight: 500;
    text-align: center;
    text-decoration: none;
  }

  body.organization-mobile-context .organization-mobile-dashboard-action:active {
    background: #eef6ff;
    border-color: #bfdbfe;
  }

  body.organization-mobile-context .organization-mobile-dashboard-action-icon {
    font-size: 20px;
    line-height: 1;
  }
}

/* ===== Phase 8: Mobile loyalty ===== */

.loyalty-mobile-section {
  display: none;
}

.loyalty-desktop-body {
  display: block;
}

@media (min-width: 768px) {
  .loyalty-mobile-section {
    display: none !important;
  }
  .loyalty-mobile-section-toggle {
    display: none !important;
  }
  .loyalty-mobile-section-content {
    display: block !important;
  }
  .loyalty-mobile-section-content[hidden] {
    display: block !important;
  }
  .loyalty-desktop-body {
    display: block !important;
  }
}

@media (max-width: 767px) {
  body.organization-mobile-context [data-loyalty] .tabs {
    display: flex;
    overflow-x: auto;
    gap: 8px;
    padding-bottom: 6px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  body.organization-mobile-context [data-loyalty] .tabs::-webkit-scrollbar {
    display: none;
  }
  body.organization-mobile-context [data-loyalty] .tabs a,
  body.organization-mobile-context [data-loyalty] .tabs .loyalty-tab-button {
    flex: 0 0 auto;
    min-height: 44px;
    white-space: nowrap;
  }
  body.organization-mobile-context [data-loyalty] .panel {
    padding: 14px;
  }
  body.organization-mobile-context [data-loyalty] .modal-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }
  body.organization-mobile-context [data-loyalty] label,
  body.organization-mobile-context [data-loyalty] input,
  body.organization-mobile-context [data-loyalty] select,
  body.organization-mobile-context [data-loyalty] textarea {
    width: 100%;
    min-height: 44px;
  }
  body.organization-mobile-context [data-loyalty] .app-table {
    display: block;
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  body.organization-mobile-context [data-loyalty] .app-table table {
    min-width: 560px;
  }
  body.organization-mobile-context .loyalty-mobile-section {
    display: grid;
    gap: 0;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    background: #fff;
    overflow: hidden;
    margin-bottom: 12px;
  }
  body.organization-mobile-context .loyalty-mobile-section-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    min-height: 48px;
    padding: 12px 14px;
    border: 0;
    background: #f9fafb;
    color: #101828;
    font-size: 15px;
    font-weight: 600;
    text-align: left;
  }
  body.organization-mobile-context .loyalty-mobile-section-toggle[aria-expanded="true"] {
    background: #eef6ff;
    color: #1d4ed8;
  }
  body.organization-mobile-context .loyalty-mobile-section-chevron {
    width: 10px;
    height: 10px;
    border-right: 2px solid currentColor;
    border-bottom: 2px solid currentColor;
    transform: rotate(-45deg);
    transition: transform 0.18s ease;
  }
  body.organization-mobile-context .loyalty-mobile-section-toggle[aria-expanded="true"] .loyalty-mobile-section-chevron {
    transform: rotate(45deg);
  }
  body.organization-mobile-context .loyalty-mobile-section-content {
    display: grid;
    gap: 12px;
    padding: 14px;
  }
  body.organization-mobile-context .loyalty-mobile-section-content[hidden] {
    display: none !important;
  }
  body.organization-mobile-context [data-loyalty] .inline-form {
    grid-template-columns: 1fr;
  }
  body.organization-mobile-context [data-loyalty] .inline-form input,
  body.organization-mobile-context [data-loyalty] .inline-form select,
  body.organization-mobile-context [data-loyalty] .inline-form button {
    min-height: 44px;
    width: 100%;
  }
  body.organization-mobile-context [data-loyalty] .client-referral-link-block input,
  body.organization-mobile-context [data-loyalty] input[data-generated-auth-link] {
    width: 100%;
    overflow-wrap: anywhere;
  }
  body.organization-mobile-context .loyalty-desktop-body {
    display: none !important;
  }
}

/* ===== Phase 9: Mobile catalog / warehouse / inventory ===== */

@media (min-width: 768px) {
  .warehouse-mobile-card,
  .warehouse-mobile-filters {
    display: none !important;
  }
}

@media (max-width: 767px) {
  body.organization-mobile-context [data-warehouse] .tabs,
  body.organization-mobile-context [data-settings-section^="catalog-"] .tabs {
    display: flex;
    overflow-x: auto;
    gap: 8px;
    padding-bottom: 6px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  body.organization-mobile-context [data-warehouse] .tabs::-webkit-scrollbar,
  body.organization-mobile-context [data-settings-section^="catalog-"] .tabs::-webkit-scrollbar {
    display: none;
  }
  body.organization-mobile-context [data-warehouse] .tabs a,
  body.organization-mobile-context [data-settings-section^="catalog-"] .tabs a {
    flex: 0 0 auto;
    min-height: 44px;
    white-space: nowrap;
  }
  body.organization-mobile-context [data-warehouse] .app-table {
    display: block;
    width: 100%;
    overflow-x: auto;
  }
  body.organization-mobile-context [data-warehouse] .app-table table {
    min-width: 520px;
  }
  body.organization-mobile-context [data-warehouse] .table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  body.organization-mobile-context [data-warehouse] .warehouse-subdivision-popover.is-open .warehouse-subdivision-menu,
  body.organization-mobile-context [data-warehouse] .warehouse-subdivision-storage-popover.is-open .warehouse-subdivision-storage-menu {
    display: block;
  }
  body.organization-mobile-context [data-warehouse] .warehouse-actions-popover.is-open .warehouse-actions-menu {
    display: grid;
  }
  body.organization-mobile-context [data-warehouse] .inline-form {
    grid-template-columns: 1fr;
  }
  body.organization-mobile-context [data-warehouse] .inline-form input,
  body.organization-mobile-context [data-warehouse] .inline-form select,
  body.organization-mobile-context [data-warehouse] .inline-form button {
    min-height: 44px;
    width: 100%;
  }
  body.organization-mobile-context [data-warehouse] [data-warehouse-modal] .modal-card {
    width: min(720px, calc(100vw - 12px));
    max-height: calc(100dvh - 12px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
    overflow-y: auto;
  }
  body.organization-mobile-context [data-inventory] .app-table {
    display: block;
    overflow-x: auto;
  }
  body.organization-mobile-context [data-inventory] .inline-form {
    grid-template-columns: 1fr;
  }
  body.organization-mobile-context [data-settings-section^="catalog-"] .modal-grid {
    grid-template-columns: 1fr;
  }
  body.organization-mobile-context [data-settings-section^="catalog-"] .app-table {
    display: block;
    overflow-x: auto;
  }
}

/* ===== Phase 10: Mobile tasks ===== */

.task-mobile-list,
.task-mobile-card {
  display: none;
}

@media (min-width: 768px) {
  .task-mobile-list {
    display: none !important;
  }
}

@media (max-width: 767px) {
  body.organization-mobile-context .task-desktop-table {
    display: none !important;
  }
  body.organization-mobile-context .task-mobile-list {
    display: grid;
    gap: 12px;
  }
  body.organization-mobile-context .task-mobile-card {
    display: grid;
    gap: 8px;
    padding: 14px;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    background: #fff;
  }
  body.organization-mobile-context .task-mobile-card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
  }
  body.organization-mobile-context .task-mobile-card-name {
    color: #101828;
    font-size: 14px;
    font-weight: 600;
    line-height: 1.3;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  body.organization-mobile-context .task-mobile-card-status {
    flex: 0 0 auto;
    padding: 3px 8px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
    white-space: nowrap;
  }
  body.organization-mobile-context .task-mobile-status-queued .task-mobile-card-status {
    background: #f2f4f7;
    color: #667085;
  }
  body.organization-mobile-context .task-mobile-status-running .task-mobile-card-status {
    background: #eef6ff;
    color: #1d4ed8;
  }
  body.organization-mobile-context .task-mobile-status-completed .task-mobile-card-status {
    background: #ecfdf3;
    color: #067647;
  }
  body.organization-mobile-context .task-mobile-status-failed .task-mobile-card-status {
    background: #fef3f2;
    color: #b42318;
  }
  body.organization-mobile-context .task-mobile-status-stopped .task-mobile-card-status {
    background: #f2f4f7;
    color: #667085;
  }
  body.organization-mobile-context .task-mobile-card-progress progress {
    width: 100%;
    height: 8px;
  }
  body.organization-mobile-context .task-mobile-card-result,
  body.organization-mobile-context .task-mobile-card-message {
    display: grid;
    gap: 4px;
  }
  body.organization-mobile-context .task-mobile-card-result span,
  body.organization-mobile-context .task-mobile-card-message span {
    color: #667085;
    font-size: 12px;
    font-weight: 500;
  }
  body.organization-mobile-context .task-mobile-card-result b {
    color: #101828;
    font-size: 13px;
    font-weight: 500;
  }
  body.organization-mobile-context .task-mobile-card-message p {
    margin: 0;
    color: #344054;
    font-size: 13px;
    overflow-wrap: anywhere;
  }
  body.organization-mobile-context .task-mobile-card-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    color: #667085;
    font-size: 12px;
  }
  body.organization-mobile-context .task-mobile-card-meta .client-delete-button {
    min-height: 44px;
    padding: 8px 14px;
  }
  body.organization-mobile-context .task-mobile-empty {
    padding: 20px;
    border: 1px dashed #d0d5dd;
    border-radius: 12px;
    background: #fafcff;
    text-align: center;
    color: #667085;
  }
}

/* ===== Phase 11: Mobile finance / expenses / breakdown ===== */

.finance-mobile-list,
.finance-mobile-card {
  display: none;
}

@media (min-width: 768px) {
  .finance-mobile-list {
    display: none !important;
  }
}

@media (max-width: 767px) {
  body.organization-mobile-context .finance-desktop-table {
    display: none !important;
  }
  body.organization-mobile-context .finance-mobile-list {
    display: grid;
    gap: 12px;
  }
  body.organization-mobile-context .finance-mobile-card {
    display: grid;
    gap: 8px;
    padding: 14px;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    background: #fff;
  }
  body.organization-mobile-context .finance-mobile-card.is-inactive {
    opacity: 0.7;
  }
  body.organization-mobile-context .finance-mobile-card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
  }
  body.organization-mobile-context .finance-mobile-card-name {
    color: #101828;
    font-size: 15px;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  body.organization-mobile-context .finance-mobile-card-salary {
    color: #1d4ed8;
    font-size: 14px;
    font-weight: 600;
    white-space: nowrap;
  }
  body.organization-mobile-context .finance-mobile-card-meta,
  body.organization-mobile-context .finance-mobile-card-details {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 12px;
    color: #667085;
    font-size: 12px;
  }
  body.organization-mobile-context .finance-mobile-card-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
  }
  body.organization-mobile-context .finance-mobile-card-actions .btn,
  body.organization-mobile-context .finance-mobile-card-actions button {
    width: 100%;
    min-height: 44px;
  }
  body.organization-mobile-context .finance-mobile-sort {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 8px;
    align-items: end;
    margin-bottom: 12px;
  }
  body.organization-mobile-context .finance-mobile-sort label {
    display: grid;
    gap: 6px;
    color: #344054;
    font-size: 13px;
    font-weight: 500;
  }
  body.organization-mobile-context .finance-mobile-sort select,
  body.organization-mobile-context .finance-mobile-sort button {
    min-height: 44px;
  }
  body.organization-mobile-context .finance-mobile-empty {
    padding: 20px;
    border: 1px dashed #d0d5dd;
    border-radius: 12px;
    background: #fafcff;
    text-align: center;
    color: #667085;
  }
  body.organization-mobile-context .finance-filter-panel,
  body.organization-mobile-context .finance-expenses-panel,
  body.organization-mobile-context .breakdown-page .finance-filter-panel {
    gap: 12px;
  }
  body.organization-mobile-context .finance-filters,
  body.organization-mobile-context .finance-expenses-form,
  body.organization-mobile-context .breakdown-filters {
    grid-template-columns: 1fr;
    gap: 10px;
  }
  body.organization-mobile-context .finance-filters label,
  body.organization-mobile-context .finance-expenses-form label,
  body.organization-mobile-context .breakdown-filters label {
    min-width: 0;
  }
  body.organization-mobile-context .finance-summary {
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }
  body.organization-mobile-context .finance-expenses-table-wrap,
  body.organization-mobile-context .finance-table-wrap {
    overflow-x: auto;
  }
}

/* ===== Phase 12: Mobile settings / schedules ===== */

@media (min-width: 768px) {
  .settings-mobile-card,
  .schedule-mobile-card {
    display: none !important;
  }
}

@media (max-width: 767px) {
  body.organization-mobile-context [data-settings] .tabs {
    display: flex;
    overflow-x: auto;
    gap: 8px;
    padding-bottom: 6px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  body.organization-mobile-context [data-settings] .tabs::-webkit-scrollbar {
    display: none;
  }
  body.organization-mobile-context [data-settings] .tabs a {
    flex: 0 0 auto;
    min-height: 44px;
    white-space: nowrap;
  }
  body.organization-mobile-context [data-settings] .app-table {
    display: block;
    width: 100%;
    overflow-x: auto;
  }
  body.organization-mobile-context [data-settings] .app-table table {
    min-width: 520px;
  }
  body.organization-mobile-context [data-settings] .panel,
  body.organization-mobile-context [data-settings] .subpanel {
    padding: 14px;
  }
  body.organization-mobile-context [data-settings] .modal-grid,
  body.organization-mobile-context [data-settings] .inline-form {
    grid-template-columns: 1fr;
    gap: 10px;
  }
  body.organization-mobile-context [data-settings] label {
    display: grid;
    gap: 6px;
  }
  body.organization-mobile-context [data-settings] input:not([type="checkbox"]):not([type="radio"]),
  body.organization-mobile-context [data-settings] select,
  body.organization-mobile-context [data-settings] textarea {
    width: 100%;
    min-width: 0;
    min-height: 44px;
  }
  body.organization-mobile-context [data-settings] input[type="checkbox"],
  body.organization-mobile-context [data-settings] input[type="radio"] {
    width: auto;
    min-height: 0;
  }
  body.organization-mobile-context [data-settings] .checkbox {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 44px;
  }
  body.organization-mobile-context [data-settings] .entity-list {
    gap: 12px;
  }
  body.organization-mobile-context [data-settings] .entity-card {
    min-height: 56px;
    padding: 12px 14px;
  }
  body.organization-mobile-context [data-settings] .permission-card,
  body.organization-mobile-context [data-settings] .permission-service {
    grid-template-columns: 1fr;
  }
  body.organization-mobile-context .schedule-page .schedule-filters {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
  }
  body.organization-mobile-context .schedule-page .schedule-grid {
    display: none !important;
  }
  body.organization-mobile-context .schedule-mobile-list {
    display: grid;
    gap: 12px;
  }
  body.organization-mobile-context .schedule-mobile-card {
    display: grid;
    gap: 8px;
    padding: 12px;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    background: #fff;
  }
  body.organization-mobile-context .schedule-mobile-card-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 600;
  }
  body.organization-mobile-context .schedule-mobile-day-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    min-height: 44px;
    padding: 8px 12px;
    border-bottom: 1px solid #f2f4f7;
    font-size: 13px;
    text-align: left;
    width: 100%;
  }
  body.organization-mobile-context .schedule-mobile-day-row:active {
    background: #f9fafb;
  }
  /* Mobile modals for schedules / finance / tasks — prevent viewport overflow and bottom-nav overlap */
  body.organization-mobile-context [data-schedule-modal] .modal-card,
  body.organization-mobile-context [data-finance-individual-modal] .modal-card,
  body.organization-mobile-context [data-finance-additional-modal] .modal-card,
  body.organization-mobile-context [data-tasks] ~ .modal-backdrop .modal-card {
    width: min(720px, calc(100vw - 12px));
    max-width: calc(100vw - 12px);
    max-height: calc(100dvh - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px) - 12px);
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }
  body.organization-mobile-context [data-schedule-modal] .modal-head,
  body.organization-mobile-context [data-finance-individual-modal] .modal-head,
  body.organization-mobile-context [data-finance-additional-modal] .modal-head {
    position: sticky;
    top: 0;
    z-index: 2;
    background: #fff;
  }
  body.organization-mobile-context [data-schedule-modal] .modal-close,
  body.organization-mobile-context [data-schedule-modal] .modal-close-icon,
  body.organization-mobile-context [data-finance-individual-modal] .modal-close-icon,
  body.organization-mobile-context [data-finance-additional-modal] .modal-close-icon {
    min-width: 44px;
    min-height: 44px;
  }
}

@media (max-width: 767px) {
  body.organization-mobile-context .settings-desktop-table {
    display: none !important;
  }
  body.organization-mobile-context .settings-mobile-list {
    display: grid;
    gap: 10px;
    margin-bottom: 12px;
  }
  body.organization-mobile-context .settings-mobile-card {
    display: grid;
    gap: 8px;
    padding: 12px;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    background: #fff;
    min-width: 0;
  }
  body.organization-mobile-context .settings-mobile-card-desc {
    overflow-wrap: anywhere;
    color: #667085;
    font-size: 13px;
    line-height: 1.4;
  }
  body.organization-mobile-context .settings-mobile-card-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    min-width: 0;
  }
  body.organization-mobile-context .settings-mobile-card-head span {
    overflow-wrap: anywhere;
    min-width: 0;
  }
  body.organization-mobile-context .settings-mobile-card-head button {
    min-height: 44px;
  }
  body.organization-mobile-context .settings-mobile-card-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
  }
  body.organization-mobile-context .settings-mobile-card-actions .ghost {
    min-height: 44px;
    min-width: 44px;
    padding: 8px 14px;
    white-space: normal;
    text-align: left;
  }
  body.organization-mobile-context .settings-mobile-card-actions .client-delete-icon-button {
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
    display: inline-grid;
    place-items: center;
  }
  body.organization-mobile-context [data-settings-section="logs"] .settings-log-desktop {
    display: none !important;
  }
  body.organization-mobile-context [data-settings-section="logs"] .settings-log-mobile {
    display: grid;
    gap: 10px;
    margin-bottom: 12px;
  }
  body.organization-mobile-context .settings-log-mobile-card {
    display: grid;
    gap: 8px;
    padding: 12px;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    background: #fff;
    min-width: 0;
  }
  body.organization-mobile-context .settings-log-mobile-card-event button {
    min-height: 44px;
    text-align: left;
    white-space: normal;
    width: 100%;
    justify-content: flex-start;
  }
  body.organization-mobile-context .settings-log-mobile-card-details {
    color: #344054;
    font-size: 13px;
    line-height: 1.4;
    overflow-wrap: anywhere;
    min-width: 0;
  }
  body.organization-mobile-context .settings-log-mobile-card-date {
    color: #667085;
    font-size: 12px;
  }
  body.organization-mobile-context .settings-log-mobile-empty {
    padding: 16px;
    border: 1px dashed #d0d5dd;
    border-radius: 12px;
    background: #fafcff;
    text-align: center;
    color: #667085;
    font-size: 14px;
  }
  body.organization-mobile-context [data-settings-section="logs"] .events-filter-control {
    min-width: 0;
    width: 100%;
  }
  body.organization-mobile-context [data-settings-section="logs"] .events-filter-control details {
    width: 100%;
    min-width: 0;
  }
  body.organization-mobile-context [data-settings-section="logs"] .events-filter-control summary {
    min-height: 44px;
  }
  body.organization-mobile-context [data-settings-section="logs"] .branch-multiselect-options label {
    min-height: 44px;
  }
}

@media (min-width: 768px) {
  body.organization-mobile-context [data-settings-section="logs"] .settings-log-mobile,
  body.organization-mobile-context [data-settings-section="logs"] .settings-log-mobile-empty {
    display: none !important;
  }
}

/* ===== Phase 14: Mobile chat core ===== */
.clients-chat-back {
  display: none;
}

@media (min-width: 768px) {
  .clients-chat-back {
    display: none !important;
  }
  body.organization-mobile-context .clients-chat-root.is-mobile-list,
  body.organization-mobile-context .clients-chat-root.is-mobile-detail {
    /* ensure desktop layout unchanged regardless of mobile flag */
  }
  body.organization-mobile-context .clients-chat-root.is-mobile-list .clients-chat-sidebar,
  body.organization-mobile-context .clients-chat-root.is-mobile-detail .clients-chat-sidebar,
  body.organization-mobile-context .clients-chat-root.is-mobile-list .clients-chat-main,
  body.organization-mobile-context .clients-chat-root.is-mobile-detail .clients-chat-main {
    display: flex !important;
  }
}

@media (max-width: 767px) {
  body.organization-mobile-context .clients-chat-backdrop {
    background: #fff;
  }
  body.organization-mobile-context .clients-chat-drawer {
    width: 100vw;
    height: 100dvh;
    max-height: 100dvh;
    flex-direction: column;
    box-shadow: none;
  }
  /* List/detail view switching — only mobile */
  body.organization-mobile-context .clients-chat-root.is-mobile-list .clients-chat-sidebar {
    display: flex;
    flex: 1 1 auto;
    min-height: 0;
  }
  body.organization-mobile-context .clients-chat-root.is-mobile-list .clients-chat-main {
    display: none !important;
  }
  body.organization-mobile-context .clients-chat-root.is-mobile-detail .clients-chat-sidebar {
    display: none !important;
  }
  body.organization-mobile-context .clients-chat-root.is-mobile-detail .clients-chat-main {
    display: flex;
    flex: 1 1 auto;
    min-height: 0;
  }
  body.organization-mobile-context .clients-chat-sidebar {
    flex: 1 1 auto;
    min-width: 0;
    border-right: 0;
  }
  body.organization-mobile-context .clients-chat-main {
    flex: 1 1 auto;
    min-height: 0;
    background: #f8fafc;
  }
  body.organization-mobile-context .clients-chat-header {
    display: grid;
    grid-template-columns: 44px 36px minmax(0, 1fr) 44px;
    align-items: center;
    gap: 6px;
    min-height: 56px;
    padding: 6px 8px;
    padding-top: calc(6px + env(safe-area-inset-top, 0px));
    position: sticky;
    top: 0;
    z-index: 3;
    background: #fff;
  }
  body.organization-mobile-context .clients-chat-back {
    display: inline-grid;
    place-items: center;
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
    padding: 0;
    margin: 0;
    border: 0;
    border-radius: 8px;
    background: #eef2f7;
    color: #172033;
    font-size: 20px;
    font-weight: 600;
    line-height: 1;
    cursor: pointer;
    flex: 0 0 44px;
  }
  body.organization-mobile-context .clients-chat-back:active {
    background: #e2e8f0;
  }
  body.organization-mobile-context .clients-chat-back:focus-visible {
    outline: 2px solid #9cc3ff;
    outline-offset: 2px;
  }
  body.organization-mobile-context .clients-chat-header .clients-chat-avatar,
  body.organization-mobile-context .clients-chat-header .clients-chat-avatar--large {
    width: 36px;
    height: 36px;
    min-width: 36px;
    min-height: 36px;
    flex: 0 0 36px;
    font-size: 13px;
  }
  body.organization-mobile-context .clients-chat-header > div {
    min-width: 0;
  }
  body.organization-mobile-context .clients-chat-messages {
    padding: 14px 12px;
    padding-bottom: 12px;
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
  body.organization-mobile-context .chat-message,
  body.organization-mobile-context .clients-chat-message {
    max-width: 86%;
    overflow-wrap: anywhere;
  }
  body.organization-mobile-context .clients-chat-message__text,
  body.organization-mobile-context .clients-chat-message__caption {
    overflow-wrap: anywhere;
    word-break: break-word;
  }
  body.organization-mobile-context .clients-chat-composer {
    position: sticky;
    bottom: 0;
    z-index: 2;
    gap: 8px;
    padding: 10px 12px calc(10px + env(safe-area-inset-bottom, 0px));
    background: #fff;
    border-top: 1px solid #e3e8f1;
  }
  body.organization-mobile-context .clients-chat-composer textarea {
    min-height: 44px;
    max-height: 96px;
    overflow-y: auto;
    min-width: 0;
    flex: 1 1 auto;
  }
  body.organization-mobile-context .clients-chat-attach {
    min-width: 44px;
    min-height: 44px;
    width: 44px;
    height: 44px;
    flex: 0 0 44px;
  }
  body.organization-mobile-context .clients-chat-send {
    min-width: 44px;
    min-height: 44px;
    flex: 0 0 auto;
    width: auto;
    padding: 0 14px;
    white-space: nowrap;
  }
  body.organization-mobile-context .clients-chat-composer {
    flex-wrap: nowrap;
  }
  body.organization-mobile-context .clients-chat-composer__body {
    min-width: 0;
    flex: 1 1 auto;
  }
  body.organization-mobile-context .clients-chat-item {
    min-height: 56px;
    padding: 10px 10px;
  }
  body.organization-mobile-context .clients-chat-item__copy strong,
  body.organization-mobile-context .clients-chat-item__copy small,
  body.organization-mobile-context .clients-chat-item__meta time {
    overflow-wrap: anywhere;
  }
  body.organization-mobile-context .clients-chat-list {
    padding: 0 8px 12px;
  }
  /* Bottom nav hidden only when mobile detail is active — chat feels like full-screen app */
  body.organization-mobile-context.clients-chat-mobile-detail .organization-mobile-bottom-nav {
    display: none !important;
  }
  body.organization-mobile-context.clients-chat-mobile-detail #root {
    padding-bottom: 0;
  }
  /* Pending attachments row should not cause body scroll on narrow screens */
  body.organization-mobile-context .clients-chat-attachments {
    gap: 8px;
    padding-bottom: 4px;
    scroll-padding: 0;
  }
  body.organization-mobile-context .clients-chat-attachment {
    min-width: 0;
  }
  body.organization-mobile-context .clients-chat-attachment__remove {
    min-width: 44px;
    min-height: 44px;
    width: 44px;
    height: 44px;
    display: inline-grid;
    place-items: center;
    font-size: 20px;
  }
  body.organization-mobile-context .clients-chat-attachment--preview .clients-chat-attachment__remove {
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
    top: 0;
    right: 0;
    font-size: 18px;
  }
  body.organization-mobile-context .clients-chat-attachment--file {
    min-height: 64px;
    align-items: center;
  }
  body.organization-mobile-context .clients-chat-attachment__file-copy strong,
  body.organization-mobile-context .clients-chat-file span:not(.clients-chat-file__icon):not(.clients-chat-file__icon *) {
    overflow-wrap: anywhere;
    word-break: break-word;
    white-space: normal;
  }
  body.organization-mobile-context .clients-chat-media-image,
  body.organization-mobile-context .clients-chat-media-video,
  body.organization-mobile-context .clients-chat-media-group {
    max-width: 100%;
    width: 100%;
  }
  body.organization-mobile-context .clients-chat-media-group {
    width: 100%;
    max-width: 100%;
  }
  body.organization-mobile-context .clients-chat-file {
    max-width: 100%;
    min-width: 0;
    width: 100%;
  }
  body.organization-mobile-context .clients-chat-message--album {
    max-width: 86%;
  }
  body.organization-mobile-context .clients-chat-composer-error {
    overflow-wrap: anywhere;
    padding-right: 4px;
  }
}

/* ===== Phase 15: Mobile chat media polish — long content & file cards ===== */
@media (max-width: 767px) {
  body.organization-mobile-context .clients-chat-message__text,
  body.organization-mobile-context .clients-chat-message__caption {
    overflow-wrap: anywhere;
    word-break: break-word;
  }
}

/* ===== CHAT UI BUGFIX 1: FAB above nav, close visibility, send width ===== */
.clients-chat-sidebar-close {
  display: none;
}
@media (max-width: 767px) {
  body.organization-mobile-context .clients-chat-fab {
    right: 16px;
    bottom: calc(64px + env(safe-area-inset-bottom, 0px) + 16px);
    z-index: 51;
  }
  body.organization-mobile-context.clients-chat-mobile-detail .clients-chat-fab {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
  }
  body.organization-mobile-context .clients-chat-sidebar__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
  }
  body.organization-mobile-context .clients-chat-sidebar__header h2 {
    min-width: 0;
    flex: 1 1 auto;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  body.organization-mobile-context .clients-chat-sidebar-close {
    display: inline-grid;
    min-width: 44px;
    min-height: 44px;
    width: 44px;
    height: 44px;
    flex: 0 0 44px;
  }
  body.organization-mobile-context .clients-chat-header {
    gap: 8px;
  }
  body.organization-mobile-context .clients-chat-header > div {
    min-width: 0;
    flex: 1 1 auto;
  }
  body.organization-mobile-context .clients-chat-header strong,
  body.organization-mobile-context .clients-chat-header span {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    overflow-wrap: anywhere;
  }
  body.organization-mobile-context .clients-chat-icon-button[data-chat-close] {
    min-width: 44px;
    min-height: 44px;
    width: 44px;
    height: 44px;
    flex: 0 0 44px;
    display: inline-grid;
    place-items: center;
  }
}

/* ===== REMOVE ZOOM / SCALE — Organization PWA mobile ===== */
@media (max-width: 767px) {
  /* Prevent iOS auto-zoom on focus: inputs must be >=16px */
  body.organization-mobile-context input,
  body.organization-mobile-context select,
  body.organization-mobile-context textarea {
    font-size: 16px !important;
  }
  /* Remove scale-on-active/hover, keep translate/opacity only */
  body.organization-mobile-context .booking-event:hover,
  body.organization-mobile-context .booking-event:focus-within,
  body.organization-mobile-context .booking-event:focus-visible {
    transform: translateY(-2px) !important;
  }
  body.organization-mobile-context .booking-event:active {
    transform: translateY(0) !important;
  }
  body.organization-mobile-context .booking-event-cluster:hover .booking-event-indicator,
  body.organization-mobile-context .booking-event-cluster:focus-within .booking-event-indicator {
    transform: none !important;
  }
  body.organization-mobile-context .clients-chat-fab:active {
    transform: translateY(0) !important;
  }
  body.organization-mobile-context .clients-chat-audio__play:active {
    transform: none !important;
  }
  body.organization-mobile-context [data-page-content].is-live-refreshing {
    transform: none !important;
  }
  body.organization-mobile-context button:active,
  body.organization-mobile-context a:active {
    scale: none !important;
  }
  /* Double-tap zoom mitigation — scoped, not global touch-action:none */
  body.organization-mobile-context button,
  body.organization-mobile-context a,
  body.organization-mobile-context [role="button"],
  body.organization-mobile-context .clients-chat-item,
  body.organization-mobile-context .booking-event,
  body.organization-mobile-context .client-mobile-card,
  body.organization-mobile-context .finance-mobile-card,
  body.organization-mobile-context .task-mobile-card,
  body.organization-mobile-context .schedule-mobile-day-row,
  body.organization-mobile-context .clients-chat-fab,
  body.organization-mobile-context .organization-mobile-nav-item {
    touch-action: manipulation;
  }
}

/* ===== LOYALTY MOBILE RULES LAYOUT FIX ===== */
@media (max-width: 767px) {
  body.organization-mobile-context .loyalty-mobile-section-content {
    padding: 12px;
  }
  body.organization-mobile-context .loyalty-mobile-section-content .subpanel {
    padding: 12px;
    gap: 12px;
    width: 100%;
    max-width: none;
    min-width: 0;
    box-sizing: border-box;
  }
  body.organization-mobile-context .loyalty-transition-rules-section,
  body.organization-mobile-context .loyalty-rules-section {
    width: 100%;
    max-width: none;
    min-width: 0;
  }
  body.organization-mobile-context .loyalty-transition-rules-section .inline-form,
  body.organization-mobile-context .loyalty-rules-section .inline-form {
    grid-template-columns: minmax(0, 1fr) !important;
    gap: 10px;
    width: 100%;
    max-width: none;
    min-width: 0;
  }
  body.organization-mobile-context .loyalty-transition-rules-section .inline-form label,
  body.organization-mobile-context .loyalty-rules-section .inline-form label,
  body.organization-mobile-context .loyalty-transition-rules-section .inline-form select,
  body.organization-mobile-context .loyalty-transition-rules-section .inline-form input,
  body.organization-mobile-context .loyalty-transition-rules-section .inline-form button {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
  }
  body.organization-mobile-context .loyalty-transition-rules-section .loyalty-transition-create {
    width: 100% !important;
    min-width: 0 !important;
    max-width: none !important;
    min-height: 44px;
    justify-content: center;
    white-space: normal;
    overflow-wrap: anywhere;
  }
  body.organization-mobile-context .loyalty-transition-rules-section table,
  body.organization-mobile-context .loyalty-rules-section table {
    width: 100%;
    display: block;
    max-width: none;
  }
  body.organization-mobile-context .loyalty-transition-rules-section table tbody,
  body.organization-mobile-context .loyalty-rules-section table tbody {
    display: grid;
    gap: 10px;
  }
  body.organization-mobile-context .loyalty-transition-rules-section table .loyalty-transition-rule-row,
  body.organization-mobile-context .loyalty-rules-section table .loyalty-rule-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 8px;
    padding: 12px;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    background: #fff;
    width: 100%;
    box-sizing: border-box;
  }
  body.organization-mobile-context .loyalty-transition-rules-section table .loyalty-transition-rule-row > td,
  body.organization-mobile-context .loyalty-rules-section table .loyalty-rule-row > td {
    grid-column: auto !important;
    padding: 0;
    min-width: 0;
    width: 100%;
  }
  body.organization-mobile-context .loyalty-transition-rules-section label span,
  body.organization-mobile-context .loyalty-rules-section label span {
    overflow-wrap: anywhere;
    min-width: 0;
  }
}

/* ===== CATALOG SECTION PICKER (mobile more sheet) ===== */
.organization-mobile-sheet-back {
  display: none;
}
@media (max-width: 767px) {
  body.organization-mobile-context .organization-mobile-sheet-back {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 44px;
    padding: 8px 12px;
    border: 0;
    border-radius: 8px;
    background: #eef2f7;
    color: #172033;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
  }
  body.organization-mobile-context .organization-mobile-sheet-back:active {
    background: #e2e8f0;
  }
}
