:root {
  --kg-mobile-nav-height: 0px;
}

.admin-topnav__mobile-profile,
.admin-topnav__mobile-profile-menu,
.mobile-bottom-nav,
.mobile-nav-layer,
.mobile-create-layer {
  display: none;
}

.mobile-workspace-page .crm-page-header {
  display: none;
}

.mobile-workspace-page .crm-page-body {
  margin: 0;
  padding: 0;
}

.mobile-workspace-page .crm-page-body > .container-xl {
  max-width: 58rem;
  padding: 1.5rem;
}

.mobile-workspace {
  display: grid;
  gap: 1.8rem;
  color: #0f172a;
}

.mobile-workspace__intro h1 {
  margin: 0;
  font-size: clamp(1.7rem, 4vw, 2.45rem);
  font-weight: 800;
  letter-spacing: -0.035em;
}

.mobile-workspace__intro p {
  margin: 0.35rem 0 0;
  color: #64748b;
  font-size: 1.02rem;
}

.mobile-workspace__metrics {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.9rem;
}

.mobile-work-metric {
  display: grid;
  grid-template-columns: 3.4rem minmax(0, 1fr) 1.25rem;
  gap: 0.8rem;
  align-items: center;
  min-height: 7.4rem;
  padding: 1.05rem;
  border: 1px solid #cbdcff;
  border-radius: 1.05rem;
  background: linear-gradient(135deg, #fff 0%, #f8fbff 100%);
  color: #0f172a;
  text-decoration: none;
  box-shadow: 0 0.4rem 1.4rem rgba(37, 99, 235, 0.04);
  transition: border-color 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

.mobile-work-metric:hover,
.mobile-work-metric:focus-visible {
  color: #0f172a;
  border-color: #8cb0ff;
  box-shadow: 0 0.7rem 1.8rem rgba(37, 99, 235, 0.1);
  transform: translateY(-1px);
}

.mobile-work-metric__icon,
.mobile-work-row__icon,
.mobile-create-action__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 3.4rem;
  height: 3.4rem;
  border-radius: 50%;
  background: #eef4ff;
  color: #1d4ed8;
}

.mobile-work-metric__icon .icon,
.mobile-work-row__icon .icon,
.mobile-create-action__icon .icon {
  width: 1.65rem;
  height: 1.65rem;
}

.mobile-work-metric__copy {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.mobile-work-metric__label {
  font-size: 0.94rem;
  font-weight: 600;
}

.mobile-work-metric__copy strong {
  margin-top: 0.05rem;
  color: #1d4ed8;
  font-size: 2rem;
  line-height: 1.1;
}

.mobile-work-metric__copy small {
  margin-top: 0.15rem;
  color: #64748b;
  font-size: 0.72rem;
}

.mobile-work-metric__arrow,
.mobile-work-row__arrow {
  color: #475569;
}

.mobile-work-metric__arrow .icon,
.mobile-work-row__arrow .icon {
  width: 1.1rem;
  height: 1.1rem;
}

.mobile-workspace__section {
  display: grid;
  gap: 0.8rem;
}

.mobile-workspace__section h2 {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 800;
}

.mobile-work-list {
  overflow: hidden;
  border: 1px solid #cbdcff;
  border-radius: 1.05rem;
  background: #fff;
}

.mobile-work-row {
  display: grid;
  grid-template-columns: 3.4rem minmax(0, 1fr) 1.25rem;
  gap: 0.9rem;
  align-items: center;
  min-height: 6rem;
  padding: 0.85rem 1rem;
  color: #0f172a;
  text-decoration: none;
}

.mobile-work-row + .mobile-work-row {
  border-top: 1px solid #dbe5f4;
}

.mobile-work-row:hover,
.mobile-work-row:focus-visible {
  color: #0f172a;
  background: #f8fbff;
}

.mobile-work-row__copy {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.mobile-work-row__copy strong {
  font-size: 1.04rem;
  font-weight: 800;
}

.mobile-work-row__copy small {
  margin-top: 0.18rem;
  color: #64748b;
  font-size: 0.78rem;
}

.mobile-work-admin-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.9rem;
}

.mobile-work-admin {
  display: grid;
  grid-template-columns: 2.6rem minmax(0, 1fr) 1.1rem;
  gap: 0.7rem;
  align-items: center;
  min-height: 4.7rem;
  padding: 0.8rem 1rem;
  border: 1px solid #cbdcff;
  border-radius: 0.95rem;
  background: #fff;
  color: #334155;
  text-decoration: none;
}

.mobile-work-admin:hover,
.mobile-work-admin:focus-visible {
  color: #1d4ed8;
  border-color: #8cb0ff;
}

.mobile-work-admin > span {
  display: inline-flex;
  color: #1d4ed8;
}

.mobile-work-admin > span .icon {
  width: 1.8rem;
  height: 1.8rem;
}

.mobile-work-admin__arrow {
  width: 1rem;
  height: 1rem;
}

@media (max-width: 600px) and (orientation: portrait) {
  :root {
    --kg-mobile-header-height: 4rem;
    --kg-mobile-nav-height: calc(4.65rem + env(safe-area-inset-bottom));
  }

  body.crm-admin-body {
    padding-bottom: var(--kg-mobile-nav-height);
  }

  body.mobile-layer-open {
    overflow: hidden;
  }

  .admin-topnav {
    position: sticky;
    top: 0;
    z-index: 1040;
    min-height: var(--kg-mobile-header-height);
    border-bottom: 1px solid #e5eaf1;
    background: rgba(255, 255, 255, 0.97);
    backdrop-filter: blur(14px);
  }

  .admin-topnav__bar {
    flex-wrap: nowrap !important;
    min-height: var(--kg-mobile-header-height) !important;
    padding: 0.55rem 1rem;
  }

  .admin-topnav__brand .admin-brand-logo {
    width: 9.2rem !important;
    max-height: 2rem !important;
  }

  .admin-topnav__toggler,
  .admin-topnav__collapse {
    display: none !important;
  }

  .admin-topnav__mobile-profile-menu {
    display: block !important;
    position: relative;
    width: auto !important;
    margin-left: auto;
  }

  .admin-topnav__mobile-profile {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: transparent;
    box-shadow: 0 0 0 1px #d8e0eb;
    cursor: pointer;
  }

  .admin-topnav__mobile-profile:focus-visible,
  .admin-topnav__mobile-profile[aria-expanded="true"] {
    outline: 0;
    box-shadow: 0 0 0 3px rgba(47, 111, 237, 0.18);
  }

  .admin-topnav__mobile-profile .avatar {
    width: 2.45rem;
    height: 2.45rem;
  }

  .admin-mobile-profile-dropdown {
    width: min(19rem, calc(100vw - 2rem));
    margin-top: 0.65rem !important;
    padding: 0.45rem;
    border: 1px solid #dce4ee;
    border-radius: 1rem;
    box-shadow: 0 1rem 2.5rem rgba(15, 23, 42, 0.18);
  }

  .admin-mobile-profile-dropdown__user {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.45rem 0.55rem;
  }

  .admin-mobile-profile-dropdown__user > span {
    display: flex;
    flex-direction: column;
    min-width: 0;
    line-height: 1.3;
  }

  .admin-mobile-profile-dropdown__user strong {
    overflow: hidden;
    color: #0f172a;
    font-size: 0.82rem;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .admin-mobile-profile-dropdown__user small {
    color: #64748b;
    font-size: 0.68rem;
  }

  .admin-mobile-profile-dropdown .dropdown-divider {
    margin: 0.35rem 0;
  }

  .admin-mobile-profile-dropdown .dropdown-item {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    min-height: 2.8rem;
    padding: 0.55rem 0.65rem;
    border-radius: 0.7rem;
    color: #334155;
    font-size: 0.78rem;
    font-weight: 650;
  }

  .admin-mobile-profile-dropdown .dropdown-item .icon {
    flex: 0 0 auto;
    width: 1.15rem;
    height: 1.15rem;
    color: #64748b;
  }

  .admin-mobile-profile-dropdown .dropdown-item:active,
  .admin-mobile-profile-dropdown .dropdown-item:hover,
  .admin-mobile-profile-dropdown .dropdown-item:focus {
    background: #eef4ff;
    color: #1d4ed8;
  }

  .admin-mobile-profile-dropdown__logout,
  .admin-mobile-profile-dropdown__logout .icon {
    color: #dc2626 !important;
  }

  .crm-footer {
    display: none;
  }

  .crm-page-body {
    padding-bottom: 1rem;
  }

  .mobile-bottom-nav {
    position: fixed;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 1080;
    display: flex !important;
    align-items: flex-start;
    justify-content: space-around;
    min-height: var(--kg-mobile-nav-height);
    padding: 0.42rem max(0.55rem, env(safe-area-inset-right)) env(safe-area-inset-bottom) max(0.55rem, env(safe-area-inset-left));
    border-top: 1px solid #dfe6ef;
    background: rgba(255, 255, 255, 0.98);
    box-shadow: 0 -0.55rem 1.7rem rgba(15, 23, 42, 0.07);
    backdrop-filter: blur(14px);
  }

  .mobile-bottom-nav__item {
    display: flex;
    flex: 1 1 0;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.16rem;
    min-width: 0;
    min-height: 3.55rem;
    padding: 0.15rem 0.25rem;
    border: 0;
    background: transparent;
    color: #475569;
    font: inherit;
    text-decoration: none;
  }

  .mobile-bottom-nav__item .icon {
    width: 1.45rem;
    height: 1.45rem;
  }

  .mobile-bottom-nav__item span {
    overflow: hidden;
    max-width: 100%;
    font-size: 0.67rem;
    font-weight: 600;
    line-height: 1.15;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .mobile-bottom-nav__item.is-active,
  .mobile-bottom-nav__item[aria-expanded="true"] {
    color: #1d4ed8;
  }

  .is-navigation-loading {
    pointer-events: none;
    color: #1d4ed8 !important;
    cursor: wait;
  }

  .mobile-navigation-spinner {
    display: inline-block;
    flex: 0 0 auto;
    width: 1.3rem;
    height: 1.3rem;
    border: 0.14rem solid rgba(29, 78, 216, 0.24);
    border-top-color: currentColor;
    border-radius: 50%;
    animation: mobile-navigation-spin 650ms linear infinite;
  }

  .mobile-navigation-loading-slot > .icon,
  .mobile-navigation-loading-icon {
    display: none !important;
  }

  .mobile-bottom-nav__item > .mobile-navigation-spinner {
    width: 1.45rem;
    height: 1.45rem;
  }

  @keyframes mobile-navigation-spin {
    to {
      transform: rotate(360deg);
    }
  }

  @media (prefers-reduced-motion: reduce) {
    .mobile-navigation-spinner {
      animation-duration: 1.3s;
    }
  }

  .mobile-bottom-nav__create {
    display: inline-flex;
    flex: 0 0 3.65rem;
    align-items: center;
    justify-content: center;
    width: 3.65rem;
    height: 3.65rem;
    margin: -0.95rem 0.2rem 0;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: linear-gradient(145deg, #2f6fed, #1948cf);
    color: #fff;
    box-shadow: 0 0.6rem 1.35rem rgba(37, 99, 235, 0.32);
  }

  .mobile-bottom-nav__create .icon {
    width: 1.8rem;
    height: 1.8rem;
  }

  .mobile-bottom-nav__create-close,
  .mobile-bottom-nav__create[aria-expanded="true"] .mobile-bottom-nav__create-plus {
    display: none;
  }

  .mobile-bottom-nav__create[aria-expanded="true"] .mobile-bottom-nav__create-close {
    display: inline-block;
  }

  .mobile-nav-layer,
  .mobile-create-layer {
    position: fixed;
    inset: 0;
    pointer-events: none;
    visibility: hidden;
    opacity: 0;
    transition: opacity 180ms ease, visibility 180ms ease;
  }

  .mobile-nav-layer {
    z-index: 1060;
  }

  .mobile-create-layer {
    z-index: 1070;
  }

  .mobile-nav-layer.is-open,
  .mobile-create-layer.is-open {
    display: block;
    pointer-events: auto;
    visibility: visible;
    opacity: 1;
  }

  .mobile-nav-layer__backdrop,
  .mobile-create-layer__backdrop {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    padding: 0;
    border: 0;
    background: rgba(15, 23, 42, 0.46);
  }

  .mobile-nav-panel {
    position: absolute;
    top: var(--kg-mobile-header-height);
    right: 0;
    bottom: var(--kg-mobile-nav-height);
    left: 0;
    overflow-y: auto;
    padding: 1rem;
    background: #fff;
    overscroll-behavior: contain;
  }

  .mobile-nav-panel__main,
  .mobile-nav-panel__category {
    width: min(100%, 44rem);
    margin: 0 auto;
  }

  .mobile-nav-panel__heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 0.9rem;
  }

  .mobile-nav-panel__heading--category {
    display: grid;
    grid-template-columns: 2.7rem minmax(0, 1fr) 2.7rem;
  }

  .mobile-nav-panel__heading h2,
  .mobile-create-sheet__heading h2 {
    margin: 0;
    color: #0f172a;
    font-size: 1.35rem;
    font-weight: 800;
  }

  .mobile-nav-panel__eyebrow {
    display: block;
    margin-bottom: 0.08rem;
    color: #64748b;
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
  }

  .mobile-nav-icon-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.7rem;
    height: 2.7rem;
    padding: 0;
    border: 1px solid #dbe3ed;
    border-radius: 50%;
    background: #fff;
    color: #475569;
  }

  .mobile-nav-icon-button .icon {
    width: 1.25rem;
    height: 1.25rem;
  }

  .mobile-nav-search {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    min-height: 3.35rem;
    padding: 0 1rem;
    border: 1px solid #bfcef0;
    border-radius: 0.9rem;
    background: #fff;
    color: #64748b;
  }

  .mobile-nav-search:focus-within {
    border-color: #4779ef;
    box-shadow: 0 0 0 3px rgba(47, 111, 237, 0.11);
  }

  .mobile-nav-search input {
    flex: 1;
    min-width: 0;
    border: 0;
    outline: 0;
    background: transparent;
    color: #0f172a;
    font: inherit;
  }

  .mobile-nav-search input::placeholder {
    color: #94a3b8;
  }

  .mobile-nav-section,
  .mobile-nav-search-results {
    margin-top: 1.35rem;
  }

  .mobile-nav-section h3,
  .mobile-nav-search-results h3 {
    margin: 0 0 0.65rem;
    color: #0f172a;
    font-size: 0.95rem;
    font-weight: 800;
  }

  .mobile-nav-quick-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.65rem;
  }

  .mobile-nav-quick-card {
    display: grid;
    grid-template-columns: 2.5rem minmax(0, 1fr);
    gap: 0.55rem;
    align-items: center;
    min-height: 4.25rem;
    padding: 0.65rem 0.75rem;
    border: 1px solid #cfddfa;
    border-radius: 0.9rem;
    background: #fff;
    color: #1e293b;
    text-decoration: none;
  }

  .mobile-nav-quick-card > span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 50%;
    background: #eef4ff;
    color: #1d4ed8;
  }

  .mobile-nav-quick-card strong {
    font-size: 0.78rem;
    line-height: 1.25;
    white-space: normal;
  }

  .mobile-nav-quick-card__arrow {
    width: 0.95rem;
    height: 0.95rem;
    color: #475569;
  }

  .mobile-nav-category-list,
  .mobile-nav-direct-list {
    overflow: hidden;
    border: 1px solid #d5e0f3;
    border-radius: 0.95rem;
    background: #fff;
  }

  .mobile-nav-category-row,
  .mobile-nav-direct-row {
    display: grid;
    grid-template-columns: 2.6rem minmax(0, 1fr) 1rem;
    gap: 0.7rem;
    align-items: center;
    width: 100%;
    min-height: 3.65rem;
    padding: 0.55rem 0.8rem;
    border: 0;
    background: #fff;
    color: #334155;
    font: inherit;
    font-size: 0.86rem;
    font-weight: 600;
    text-align: left;
    text-decoration: none;
  }

  .mobile-nav-direct-row {
    grid-template-columns: 2.6rem minmax(0, 1fr);
  }

  .mobile-nav-category-row + .mobile-nav-category-row,
  .mobile-nav-category-row + .mobile-nav-direct-row,
  .mobile-nav-direct-row + .mobile-nav-direct-row {
    border-top: 1px solid #e2e8f0;
  }

  .mobile-nav-category-row:hover,
  .mobile-nav-category-row:focus-visible,
  .mobile-nav-direct-row:hover,
  .mobile-nav-direct-row:focus-visible,
  .mobile-nav-direct-row.is-active {
    background: #eef4ff;
    color: #1d4ed8;
  }

  .mobile-nav-category-row__icon,
  .mobile-nav-direct-row__icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.4rem;
    height: 2.4rem;
    border-radius: 50%;
    background: #f1f5f9;
    color: #1d4ed8;
  }

  .mobile-nav-category-row__icon .icon,
  .mobile-nav-direct-row__icon .icon {
    width: 1.3rem;
    height: 1.3rem;
  }

  .mobile-nav-category-row__arrow,
  .mobile-nav-direct-row__arrow {
    width: 0.95rem;
    height: 0.95rem;
  }

  .mobile-nav-category-caption {
    margin: -0.2rem 0 0.85rem;
    color: #64748b;
    font-size: 0.82rem;
  }

  .mobile-nav-search-empty {
    margin: 0.75rem 0 0;
    color: #64748b;
    text-align: center;
  }

  .mobile-create-sheet {
    position: absolute;
    right: 0;
    bottom: var(--kg-mobile-nav-height);
    left: 0;
    max-height: calc(100dvh - var(--kg-mobile-header-height) - var(--kg-mobile-nav-height));
    overflow-y: auto;
    padding: 0.55rem 1rem 1rem;
    border-radius: 1.4rem 1.4rem 0 0;
    background: #fff;
    box-shadow: 0 -1.4rem 3rem rgba(15, 23, 42, 0.17);
    transform: translateY(1rem);
    transition: transform 180ms ease;
  }

  .mobile-create-layer.is-open .mobile-create-sheet {
    transform: translateY(0);
  }

  .mobile-create-sheet__handle {
    width: 3.2rem;
    height: 0.3rem;
    margin: 0 auto 0.65rem;
    border-radius: 999px;
    background: #cbd5e1;
  }

  .mobile-create-sheet__heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.75rem;
  }

  .mobile-create-sheet__heading p {
    margin: 0.18rem 0 0;
    color: #64748b;
    font-size: 0.82rem;
  }

  .mobile-create-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.65rem;
    margin-top: 0.9rem;
  }

  .mobile-create-action {
    display: grid;
    grid-template-columns: 3rem minmax(0, 1fr);
    gap: 0.65rem;
    align-items: center;
    min-height: 5.2rem;
    padding: 0.7rem;
    border: 1px solid #cfddfa;
    border-radius: 0.9rem;
    background: #fff;
    color: #0f172a;
    text-decoration: none;
  }

  .mobile-create-action:hover,
  .mobile-create-action:focus-visible {
    color: #0f172a;
    border-color: #7fa3f7;
    background: #f8fbff;
  }

  .mobile-create-action__icon {
    width: 3rem;
    height: 3rem;
  }

  .mobile-create-action > span:last-child {
    display: flex;
    flex-direction: column;
    min-width: 0;
  }

  .mobile-create-action strong {
    font-size: 0.84rem;
  }

  .mobile-create-action small {
    margin-top: 0.12rem;
    color: #64748b;
    font-size: 0.68rem;
  }

  .mobile-workspace-page .crm-page-body > .container-xl {
    padding: 1.25rem 1rem 1.5rem;
  }

  .mobile-workspace {
    gap: 1.45rem;
  }

  .mobile-workspace__intro h1 {
    font-size: 1.85rem;
  }

  .mobile-workspace__intro p {
    font-size: 0.92rem;
  }

  .mobile-workspace__metrics {
    gap: 0.7rem;
  }

  .mobile-work-metric {
    grid-template-columns: 2.85rem minmax(0, 1fr) 0.85rem;
    gap: 0.55rem;
    min-height: 6.3rem;
    padding: 0.75rem;
    border-radius: 0.9rem;
  }

  .mobile-work-metric__icon,
  .mobile-work-row__icon {
    width: 2.85rem;
    height: 2.85rem;
  }

  .mobile-work-metric__icon .icon,
  .mobile-work-row__icon .icon {
    width: 1.45rem;
    height: 1.45rem;
  }

  .mobile-work-metric__label {
    font-size: 0.78rem;
  }

  .mobile-work-metric__copy strong {
    font-size: 1.65rem;
  }

  .mobile-work-row {
    grid-template-columns: 2.85rem minmax(0, 1fr) 1rem;
    min-height: 5.4rem;
    padding: 0.7rem 0.8rem;
  }

  .mobile-work-row__copy strong {
    font-size: 0.96rem;
  }

  .mobile-work-row__copy small {
    font-size: 0.72rem;
  }

  .mobile-workspace__section h2 {
    font-size: 1.05rem;
  }
}

@media (max-width: 420px) {
  .mobile-nav-panel,
  .mobile-create-sheet {
    padding-right: 0.8rem;
    padding-left: 0.8rem;
  }

  .mobile-bottom-nav__item span {
    font-size: 0.62rem;
  }

  .mobile-work-metric {
    grid-template-columns: 2.55rem minmax(0, 1fr) 0.7rem;
    padding: 0.62rem;
  }

  .mobile-work-metric__icon {
    width: 2.55rem;
    height: 2.55rem;
  }

  .mobile-create-grid {
    gap: 0.5rem;
  }

  .mobile-create-action {
    grid-template-columns: 2.6rem minmax(0, 1fr);
    gap: 0.5rem;
    padding: 0.6rem;
  }

  .mobile-create-action__icon {
    width: 2.6rem;
    height: 2.6rem;
  }
}

/* Keep iOS Safari at the current page scale when focusing mobile form controls. */
@media (max-width: 767.98px) {
  html {
    -webkit-text-size-adjust: 100%;
  }

  input.form-control,
  select.form-select,
  textarea.form-control,
  .crm-searchable-input {
    font-size: 16px !important;
  }
}
