/* v5.9.7: buscador y perfil en cabecera superior */
.compact-topbar.thmail-central-header {
  min-height: 72px !important;
  height: auto !important;
  display: grid !important;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 12px 0 10px !important;
}

.thmail-central-header .thmail-header-search {
  width: 100%;
  min-width: 0;
  height: 44px;
  margin: 0;
  background: #ffffff;
}

.thmail-central-header .thmail-header-account {
  position: relative;
  justify-self: end;
  align-self: center;
  margin: 0;
}

.thmail-central-header .profile-btn {
  width: 42px !important;
  height: 42px !important;
  min-width: 42px;
  border-radius: 999px !important;
  box-shadow: 0 8px 18px rgba(18, 104, 255, .18);
}

.thmail-central-header .account-menu {
  right: 0;
  left: auto;
  top: calc(100% + 8px);
  z-index: 120;
}

/* Los filtros quedan en una fila propia, sin espacios vacíos */
.compact-mail-filters {
  grid-template-columns:
    auto
    auto
    minmax(150px, 190px) !important;
  justify-content: start;
  align-items: center;
}

.compact-mail-filters .compact-search-wrap,
.compact-mail-filters .compact-account-wrap {
  display: none !important;
}

/* Cabecera de carpeta en dos columnas */
.list-head {
  display: grid !important;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center !important;
  justify-content: stretch;
  gap: 12px;
}

.list-head > div {
  min-width: 0;
}

.list-head .refresh-icon-btn {
  justify-self: end;
  align-self: center;
  margin: 0;
}

/* Alineación segura checkbox / avatar */
.message-item {
  align-items: start;
}

@media (max-width: 900px) {
  .compact-topbar.thmail-central-header {
    min-height: 70px !important;
    padding: 10px 10px 8px 48px !important;
    gap: 10px;
  }

  .thmail-central-header .thmail-header-search {
    height: 42px;
    padding-inline: 14px;
  }

  .thmail-central-header .profile-btn {
    width: 42px !important;
    height: 42px !important;
  }

  .compact-mail-filters {
    grid-template-columns:
      minmax(0, 1fr)
      minmax(0, 1fr) !important;
    gap: 10px !important;
  }

  .compact-mail-filters #sortSelect {
    grid-column: 1 / -1;
    width: 100%;
  }

  .list-head {
    grid-template-columns: minmax(0, 1fr) auto !important;
    align-items: center !important;
    padding: 18px !important;
  }

  .list-head h2 {
    margin: 0;
  }

  .list-head p {
    margin-top: 4px;
  }
}

@media (max-width: 620px) {
  .compact-topbar.thmail-central-header {
    padding-left: 46px !important;
    padding-right: 10px !important;
  }

  .thmail-central-header .thmail-header-search {
    min-width: 0;
  }

  .thmail-central-header .profile-btn {
    width: 40px !important;
    height: 40px !important;
    min-width: 40px;
  }

  .list-head {
    padding: 18px 16px !important;
  }

  .list-head h2 {
    font-size: 25px;
  }

  .message-item {
    grid-template-columns:
      34px
      minmax(0, 1fr) !important;
    align-items: start !important;
  }

  .message-check {
    display: grid !important;
    place-items: start center !important;
    align-self: start !important;
    padding: 27px 0 0 !important;
  }

  .message-check input {
    margin: 0 !important;
  }

  .message-open {
    grid-template-columns:
      42px
      minmax(0, 1fr) !important;
    gap: 10px !important;
    align-items: start !important;
    padding: 14px 14px 14px 0 !important;
  }

  .avatar {
    width: 42px;
    height: 42px;
    justify-self: center !important;
    align-self: start !important;
  }

  .message-main {
    align-self: start;
    padding-left: 0 !important;
  }

  .msg-time {
    grid-column: 2;
    justify-self: start;
    align-self: start;
    margin-top: 3px;
    padding-top: 0;
  }
}
