/* Opright app-wide visual recovery layer.
 * Keep this file last so feature modules, iOS safe areas, and stacked dialogs
 * share one dependable final contract.
 */

#appView,
#modal,
#guideRoot,
#employeePreviewBanner {
  -webkit-tap-highlight-color: transparent;
}

#appView main {
  min-width: 0;
  overflow-x: clip;
  scroll-padding-bottom: calc(150px + env(safe-area-inset-bottom, 0px));
}

/* Bottom navigation is an equal-width grid. Permission filtering may change
 * the number of visible tabs, but must never shrink a button inside its cell. */
#appView .tabs > button:not(.hidden) {
  width: 100% !important;
  max-width: none !important;
  min-width: 0;
}

/* Settings modules may choose their own grid/flex display. The organizer's
 * suppression state always wins while browsing the Settings hub. */
#appView #settings.settingsOrganized .settingsManagedPanel.settingsHubSuppressed,
#appView #settings.settingsOrganized [data-settings-group].settingsHubSuppressed {
  display: none !important;
}

#appView :is(button, a, input, select, textarea),
#modal :is(button, a, input, select, textarea),
#employeePreviewBanner button {
  touch-action: manipulation;
}

/* Work and Workflows */
#appView .workHero {
  color: #fff;
}

#appView .workHero :is(h1, h2, h3, h4) {
  color: #fff;
}

#appView .workHero p {
  color: #d5e0dd;
}

#appView .workCardTop > div:first-child {
  flex: 1 1 auto;
  min-width: 0;
}

#appView .workCardTitle,
#appView .workCardMeta {
  overflow-wrap: break-word;
  word-break: normal;
}

#appView .workCardAside {
  flex: 0 0 auto;
}

#appView .workCardActions {
  align-items: stretch;
}

#appView .workCardActions :is(button, a) {
  display: inline-flex;
  min-height: 38px;
  align-items: center;
  justify-content: center;
}

#appView .workLinkBox {
  min-width: 0;
}

#appView .workLinkBox span {
  flex: 1 1 auto;
  min-width: 0;
  overflow: visible;
  overflow-wrap: anywhere;
  color: #52675d;
  line-height: 1.45;
  text-overflow: clip;
  white-space: normal;
}

#appView .workLinkBox button {
  min-height: 40px;
  flex: 0 0 auto;
}

#appView .workToggle > span {
  flex: 1 1 auto;
  min-width: 0;
}

/* Plan and billing */
#appView .launchAccessBanner {
  position: relative;
  overflow: hidden;
  margin-bottom: 14px;
  padding: clamp(17px, 3vw, 21px);
  border-radius: 18px;
  background: linear-gradient(135deg, #010510, #0b2f70);
  color: #fff;
  box-shadow: 0 18px 42px rgb(1 5 16 / 15%);
}

#appView .launchAccessBanner::after {
  position: absolute;
  right: -45px;
  bottom: -70px;
  width: 180px;
  height: 180px;
  border-radius: 50%;
  background: rgb(8 119 255 / 13%);
  content: "";
  pointer-events: none;
}

#appView .launchAccessBadge {
  position: relative;
  z-index: 1;
  display: inline-flex;
  padding: 6px 9px;
  border-radius: 999px;
  background: #0877ff;
  color: #010510;
  font-size: 9px;
  font-weight: 950;
  letter-spacing: .08em;
}

#appView .launchAccessBanner h3 {
  position: relative;
  z-index: 1;
  margin: 10px 0 6px;
  color: #fff !important;
  font-size: clamp(20px, 4vw, 23px);
  line-height: 1.15;
}

#appView .launchAccessBanner p {
  position: relative;
  z-index: 1;
  max-width: 620px;
  margin: 0;
  color: #dce8e3;
  font-size: 11px;
  line-height: 1.55;
}

#appView .launchAccessFacts {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 7px;
  margin-top: 15px;
}

#appView .launchAccessFacts > span {
  padding: 9px;
  border: 1px solid rgb(255 255 255 / 14%);
  border-radius: 11px;
  background: rgb(255 255 255 / 5%);
  color: #e7efec;
  font-size: 9px;
  font-weight: 800;
  line-height: 1.4;
  overflow-wrap: normal;
  word-break: normal;
}

#appView .launchAccessFacts b {
  display: block;
  margin-bottom: 2px;
  color: #65c8ff;
  font-size: 10px;
}

#appView .planHeaderTop > div:first-child {
  flex: 1 1 auto;
  min-width: 0;
}

#appView .planStatusPill {
  flex: 0 0 auto;
  overflow-wrap: normal;
  text-align: center;
  white-space: nowrap;
  word-break: normal;
}

#appView .billingToggle {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  width: min(100%, 360px);
}

#appView .billingToggle > button {
  min-height: 42px;
  white-space: normal;
}

/* Data migration */
#appView .migrationHero h3 {
  color: #fff !important;
}

#appView .migrationHero p {
  color: #dce7e2;
}

#appView .migrationSteps span {
  overflow-wrap: normal;
  word-break: normal;
}

#appView .migrationSectionHead > div:first-child,
#appView .migrationFileCard > div:first-child {
  flex: 1 1 auto;
  min-width: 0;
}

#appView .migrationSectionHead .secondary {
  flex: 0 0 auto;
}

/* Modal and front-layer rules */
body:has(#modal.open) {
  overflow: hidden;
}

body:has(#modal.open) #guideRoot {
  visibility: hidden;
  pointer-events: none;
}

#modal {
  padding-top: max(10px, env(safe-area-inset-top, 0px));
  padding-right: env(safe-area-inset-right, 0px);
  padding-left: env(safe-area-inset-left, 0px);
}

#modal .sheet {
  max-height: calc(100dvh - max(10px, env(safe-area-inset-top, 0px)));
}

#modal .modalhead {
  isolation: isolate;
}

#modal .close {
  width: 44px;
  height: 44px;
  min-height: 44px;
  flex-basis: 44px;
}

.invoiceShareComposer {
  z-index: 13000;
}

/* Employee preview occupies its own safe row above the workspace header. */
#employeePreviewBanner {
  position: fixed;
  top: calc(env(safe-area-inset-top, 0px) + 8px);
  right: max(12px, env(safe-area-inset-right, 0px));
  left: max(12px, env(safe-area-inset-left, 0px));
  z-index: 10000;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  min-height: 52px;
  align-items: center;
  gap: 10px;
  padding: 6px 7px 6px 14px;
  border: 1px solid rgb(255 255 255 / 12%);
  border-radius: 15px;
  background: #010510;
  color: #fff;
  box-shadow: 0 12px 32px rgb(1 5 16 / 28%);
  font-size: 12px;
  font-weight: 850;
}

#employeePreviewBanner span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#employeePreviewBanner button {
  min-width: 108px;
  min-height: 44px;
  padding: 9px 12px;
  border: 0;
  border-radius: 11px;
  background: #fff;
  color: #010510;
  font-size: 11px;
  font-weight: 900;
}

body.employee-preview {
  padding-top: 0 !important;
}

body.employee-preview #appView {
  padding-top: calc(env(safe-area-inset-top, 0px) + 72px);
}

body.employee-preview #appView .top {
  top: calc(env(safe-area-inset-top, 0px) + 72px);
  height: 70px;
  padding-top: 10px;
}

/* Coarse pointers need a complete 44px iPhone hit area. */
@media (hover: none) and (pointer: coarse) {
  #appView button:not(.contextInfoTrigger):not(.workRemoveLine),
  #modal button,
  #employeePreviewBanner button {
    min-height: 44px;
  }

  #appView .workspaceHeaderButton {
    width: 44px;
    height: 44px;
  }
}

@media (max-width: 620px) {
  #appView .launchAccessFacts {
    grid-template-columns: 1fr;
  }

  #appView .workCardTop {
    align-items: flex-start;
  }

  #appView .workCardAside {
    max-width: 38%;
    white-space: normal;
  }

  #appView .migrationSectionHead {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
  }

  #appView .migrationSectionHead .secondary {
    width: 100%;
  }
}

@media (max-width: 420px) {
  #appView main {
    padding-right: 13px;
    padding-left: 13px;
  }

  #appView .workspaceHeaderActions {
    gap: 5px;
  }

  #appView .workspaceHeaderButton {
    width: 40px;
    height: 40px;
  }

  #appView .workMetrics,
  #appView .planUsageGrid {
    grid-template-columns: 1fr 1fr;
  }

  #appView .workCardActions :is(button, a) {
    flex: 1 1 calc(50% - 4px);
  }

  #appView .migrationHero {
    padding: 18px;
  }

  #appView .migrationSteps {
    gap: 7px;
  }

  #employeePreviewBanner {
    left: max(8px, env(safe-area-inset-left, 0px));
    right: max(8px, env(safe-area-inset-right, 0px));
    padding-left: 11px;
  }

  #employeePreviewBanner button {
    min-width: 96px;
  }
}

@media (max-width: 350px) {
  #appView .planHeaderTop {
    display: grid;
  }

  #appView .planStatusPill {
    justify-self: start;
  }

  #employeePreviewBanner {
    grid-template-columns: 1fr;
  }

  #employeePreviewBanner button {
    width: 100%;
  }

  body.employee-preview #appView {
    padding-top: calc(env(safe-area-inset-top, 0px) + 124px);
  }

  body.employee-preview #appView .top {
    top: calc(env(safe-area-inset-top, 0px) + 124px);
  }
}

